regexp.compile() 函数
regexp.compile() 将字符串解析为正则表达式,并返回一个可以用于与字符串匹配的regexp类型。
函数类型签名
(v: string) => regexp
有关更多信息,请参见 Function type signatures。
参数
v
(必需) 要解析为正则表达式的字符串值。
示例
将字符串转换为正则表达式
import "regexp"
regexp.compile(v: "abcd")// Returns the regexp object /abcd/