|
Boost Users : |
Subject: [Boost-users] Pattern issue with boost::regex
From: Tal Shnaiderman (STAL_at_[hidden])
Date: 2014-10-23 04:12:23
Hi All,
I have a question regarding boost::regex pattern recognition and groups
I created the following code, in it i created a pattern and a string to
match:
1
2
3
4
5
6
p = "((a b (f+\\.))d d(\\3))";
str="a b ffff.d dfff.";
boost::regex pattern(p, boost::regex::icase&boost::regex::extended
&~boost::regex::no_bk_refs);
bool match = boost::regex_match(str, pattern);
cout << str << ((match)?"-Pattern is legal":"-Pattern is illegal" )<<
endl;
Pattern is illegal
I'm saw that my result is 'Pattern is illegal' because the group \\3 that
refers to (f+\\.) isn't equal to it. if I change the input to
str="a b ffff.d dffff.";
The pattern is legal.
In other words my original plan was to use the \\3 instead of writing the
pattern;
p = "((a b (f+\\.))d d(f+\\.))";
But I can see that in the original pattern it simply expect the same
output to reappear
Is there a way I can use the group naming not to copy the (f+\\.) group?
Thanks, I hope my Q is clear since I'm new to the regex topic.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net