uri正则表达式模式匹配

时间:2013-01-14 03:15:00

标签: c++ regex boost

我无法将网址与

匹配
 sregex rex = sregex::compile("(?:ftp|http|https)+://([\\S\^<\^>]+)", sregex::icase );

它匹配所有网址,但它还包括&gt;&gt;在每场比赛结束时,我试图否定。我做错了什么?

1 个答案:

答案 0 :(得分:1)

我相信你想要的是:

 sregex rex = sregex::compile("(?:ftp|http|https)://([\\S]+[^<>]*)", sregex::icase );

^是集合的第一个字符时,字符^仅表示“不”。因此,^中的[\\S\^<\^>]+并不代表“不是”。当^不是集合的第一个字符时,它表示beginning of a target sequence or follows a line terminator,或者没有特殊含义。