Opened 13 years ago
Closed 13 years ago
#3941 closed Bugs (invalid)
match_results relies on string evaluated by regex_search()
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | Boost 1.43.0 | Component: | regex |
Version: | Boost 1.40.0 | Severity: | Optimization |
Keywords: | Cc: |
Description
See example: If "text" is altered or destroyed, "matches" becomes invalid. Is this the desired behavior?
string pattern="
s*:(
S+)
s*"; string text=" :command ";
boost::regex re(pattern);
boost::match_results<string::const_iterator> matches; bool stat=boost::regex_search(text, matches, re); text=""; Truncate string cout<<matches[1].str()<<endl; <<Throws sting iterator not dereferencable exception
Note:
See TracTickets
for help on using tickets.
This is by design: match_results store iterators, not strings.