Opened 11 years ago
Closed 10 years ago
#6213 closed Bugs (worksforme)
Escaping close parentheses doesn't work in boost::regex
Reported by: | anonymous | Owned by: | John Maddock |
---|---|---|---|
Milestone: | To Be Determined | Component: | regex |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Currently I am running Boost 1.47 on Scientific Linux 6 and cannot get the escaped close parentheses to match in a very simple expression. I can remove the escaped close parentheses and the regular expression will match, but with the escaped close parentheses, we never can get the if statement to work. I can put a small work around in our codebase, but I would expect this feature to work. Below is a example snippet of code:
void MyFuction(const std::string& val) { boost::regex expr1("(.*)\\((.*)\\)"); boost::regex expr2("(.*)\\((.*)"); boost::cmatch matches; if(boost::regex_match(val.c_str(), matches, expr1)) { //never will get in here } if(boost::regex_match(val.c_str(), matches, expr2)) { //will get in here when we expect it to } }
I appologize if there's something on my side that I'm missing, but I searched around and really can't find anything in our code base that would indicate its our code base and not boost::regex.
Change History (4)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Component: | None → regex |
---|---|
Owner: | set to |
comment:3 by , 11 years ago
As Steven says, we need to see the string that failed to match to tell you what's going on. My suspicion is that the string has content after the closing ")" in which case regex_match will fail (remember regex match only succeeds if the whole of the text was matched).
comment:4 by , 10 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Closed pending further information from the user.
It seems to work with MSVC 10 with the trunk:
I don't see any obvious recent changes that would affect this. Do you have an example string that fails to match?