开发者

how to match all group and subgroup in pcre

开发者 https://www.devze.com 2022-12-29 05:34 出处:网络
a ip or other string, like \"11.22.33.44\" or \"aa.bb.cc.dd\". basically, I think it is very easy, (([\\d\\w]+)+\\.)+[\\d\\w]+

a ip or other string, like "11.22.33.44" or "aa.bb.cc.dd". basically, I think it is very easy, (([\d\w]+)+\.)+[\d\w]+ but the problem is which group these submatches are in. not like ip, some string is consist of lots of words+separate

in pcre, I don't know how to 开发者_开发百科extract it all words -- "aa bb cc dd ..."


You need to do like (\w+)\.(\w+)\.(\w+)\.(\w+)

Apparantly, Only perl6 and .net regex can extract subgroups

Note: \w =>[a-zA-Z0-9_]

0

精彩评论

暂无评论...
验证码 换一张
取 消