2015-12-05 27 views
0
string sContent="the path is e:\\develop\\East\\parser(delay)"; 
string path="e:\\develop\\East\\parser(delay)"; 

char sRegex[128]; sprintf(sRegex, "\\Q%s\\E", src_str); 

pcrecpp::RE(sRegex).PartialMatch(sContent); 

它不匹配,原因"\\East" will abort '\Q'。如何解決此錯誤?pcre Q和 E匹配錯誤

回答

0

是的,這是一個與\Q .. \E功能的問題。

而不是使用它,你可以使用string quoted = RE::QuoteMeta(src_str);將轉義所有特殊字符的正則表達式中包含反斜線的字符串。

source:QUOTING METACHARACTERS

+0

很好,它運作良好! – guardiola