救命!提升正则表达式异常 [英] Help! Boost regular expression exception
问题描述
正则表达式:(?< = \D | ^)(1 [358] \d {9})(?= \D | $)
当我使用boost regex时
:
char pat [] = { (?< = \\D | ^)(1 [358] \\\ \\d {9})(= \\D | $)跨度>}?;
boost :: regex reg(pat);
这里抛出异常!
如果我使用POSIX,没有异常,但无法匹配,例如:
boost :: regex reg(pat,regbase :: basic_syntax_group);
std :: string str(+ 86 18601234567 tel。);
bool matched = regex_match(str,reg); //假!!!
谁能告诉我这是怎么回事?请发送电子邮件至jianggx@hotmail.com,谢谢!
我尝试过:
当我使用C#时,没关系。
例如:
< span class =code-keyword> string pat = @ (?< = \ D | ^)(1 [358] \d {9})(= \D | $)跨度>?;
string myinfo = 自定义名称:name1 ;电话:+86 18601234567;地址:北京。;
Regex rg = new 正则表达式(模式);
MatchCollection mc = rg.Matches(myinfo);
)
当我使用boost regex时:
char pat [] = { (?< = \\D | ^)(1 [358] \ \d {9})(= \\D |
)跨度>}?;
boost :: regex reg(pat);
这里抛出异常!
如果我使用POSIX,没有异常,但无法匹配,例如:
boost :: regex reg(pat,regbase :: basic_syntax_group);
std :: string str(+ 86 18601234567 tel。);
bool matched = regex_match(str,reg); //假!!!
谁能告诉我这是怎么回事?请发送电子邮件至jianggx@hotmail.com,谢谢!
我尝试过:
当我使用C#时,没关系。
例如:
< span class =code-keyword> string pat = @ (?< = \ D | ^)(1 [358] \d {9})(= \D |
)跨度>?;
string myinfo = 自定义名称:name1 ;电话:+86 18601234567;地址:北京。;
Regex rg = new 正则表达式(模式);
MatchCollection mc = rg.Matches(myinfo);
Regular Expression: (?<=\D|^)(1[358]\d{9})(?=\D|$)
when I use boost regex:
char pat[] = {"(?<=\\D|^)(1[358]\\d{9})(?=\\D|$)"};
boost::regex reg(pat);
here throw an exception!
If I use POSIX, no exception, but can't match, for example:
boost::regex reg(pat, regbase::basic_syntax_group);
std::string str("+86 18601234567 tel.");
bool matched = regex_match(str, reg); // false!!!
who can tell me what's the matter? Pls send email to jianggx@hotmail.com, thanks!
What I have tried:
when I use C#, it's ok.
for example:
string pat = @"(?<=\D|^)(1[358]\d{9})(?=\D|$)";
string myinfo= "custom name: name1;tel:+86 18601234567;addr:beijing.";
Regex rg = new Regex(pattern);
MatchCollection mc = rg.Matches(myinfo);
)
when I use boost regex:
char pat[] = {"(?<=\\D|^)(1[358]\\d{9})(?=\\D|
)"}; boost::regex reg(pat);
here throw an exception!
If I use POSIX, no exception, but can't match, for example:
boost::regex reg(pat, regbase::basic_syntax_group);
std::string str("+86 18601234567 tel.");
bool matched = regex_match(str, reg); // false!!!
who can tell me what's the matter? Pls send email to jianggx@hotmail.com, thanks!
What I have tried:
when I use C#, it's ok.
for example:
string pat = @"(?<=\D|^)(1[358]\d{9})(?=\D|
)"; string myinfo= "custom name: name1;tel:+86 18601234567;addr:beijing."; Regex rg = new Regex(pattern); MatchCollection mc = rg.Matches(myinfo);
这篇关于救命!提升正则表达式异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!