regexp.matchRegexpString() 函数
regexp.matchRegexpString() 测试一个字符串是否包含与正则表达式的任何匹配。
函数类型签名
(r: regexp, v: string) => bool
有关更多信息,请参见 Function type signatures。
参数
r
(必填)
用于搜索 v 的正则表达式。
v
(必填) 要搜索的字符串值。
示例
测试字符串是否包含正则表达式匹配
import "regexp"
regexp.matchRegexpString(r: /(gopher){2}/, v: "gophergophergopher")// Returns true
筛选包含与正则表达式匹配的行
import "regexp"
import "sampledata"
sampledata.string()
|> filter(fn: (r) => regexp.matchRegexpString(r: /_\d/, v: r._value))