This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/61424] std::regex matches right to left, not leftmost longest
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 05 Jun 2014 21:06:42 +0000
- Subject: [Bug libstdc++/61424] std::regex matches right to left, not leftmost longest
- Auto-submitted: auto-generated
- References: <bug-61424-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61424
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
A slight variation:
#include <regex>
#include <iostream>
using namespace std;
int main()
{
regex_constants::syntax_option_type grammar[] = {
regex_constants::ECMAScript, regex_constants::extended,
regex_constants::awk, regex_constants::egrep
};
for (auto g : grammar)
{
regex re("tour|tournament|tourn", g);
const char str[] = "tournament";
cmatch m;
if (regex_search(str, m, re))
cout << m[0] << endl;
else
cout << "-" << endl;
}
}
ECMAscript should match "tour", the POSIX ERE grammars should match
"tournament"
Instead we match "tourn" for all grammars.