bsubmatch
函数主要是用来使用正则表达式 s1 来匹配 s2,返回 map[string]string 类型结果,注:只返回具名的正则匹配结果 (?P<name>…)
格式
func (s1 string) bsubmatches(b1 bytes) map[string]string
参数名称 | 参数介绍 |
---|---|
s1 | 正则匹配语句 |
b1 | 待匹配的数据 |
(?P<name>pattern)
"^SSH-([\\d.]+)-OpenSSH_(?P<version0>[\\w._-]+) Debian-(?P<version1>\\S*maemo\\S*)\\r?\\n"
\w
、\d
、\n
等都被替换成了\\w
、\\d
、\\n
,这是因为需要规避yaml的转译