Skip to content

引入

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

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

// 只支持 ESM 的项目
import { getMatchListFromReg, getPreReleaseTag} from 't-comm/es/base/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