Skip to content

引入

ts
import { getMatchListFromReg, getPreReleaseTag } from 't-comm';

// 不支持 tree-shaking 的项目
import { getMatchListFromReg, getPreReleaseTag} from 't-comm/lib/regexp/index';

// 只支持 ESM 的项目
import { getMatchListFromReg, getPreReleaseTag} from 't-comm/es/regexp/index';

getMatchListFromReg(content, reg)

描述:匹配正则,获取匹配到的列表

参数

参数名类型描述
contentstring输入内容
regRegExp正则

返回: 匹配列表

示例

ts
getMatchListFromReg(content, /emit\('([^',]+)'/g);

// ['start', 'end']

getPreReleaseTag(version)

描述:获取预发布版本标签,比如 alpha, beta

参数

参数名类型描述
versionstring版本号

返回: 标签

示例

ts
getPreReleaseTag('1.2.2-beta.0')
// beta