救命!提升正则表达式异常 [英] Help! Boost regular expression exception

查看:86
本文介绍了救命!提升正则表达式异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正则表达式:(?< = \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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆