What's wrong in regular expression
Hello! I wrote the regular expression: ^\s*(?:([A-Za-z_]*)\s*=\s*([A-Za-z0-9_/\.]*)\s*)*$ for splitting lines like: name = abc value1 = def value2 = ghi I need the result like: match [1] = name match [2] = abc ... match [6] = ghi But I get ! : match [1] = value2 match [2] = ghi (the last 2 matches) What is wrong in my expression? Thank You. --------------------------------- Вы уже с Yahoo!? Испытайте обновленную и улучшенную Yahoo! Почту!
I was wondering if anyone knew of a publicly available class library that suports? Perhaps there is even something in boost? What I'm after is something that would enable me to implement something along the following lines: Series a("[0-9,1]"); Series b("[a-z,2]"); Series c("[A-E0-9,3]"); Series::iterator i; for (i=a.begin();i!=a.end();itr++) cout << *i; cout << endl; for (i=b.begin();i!=b.end();itr++) cout << *i; cout << endl; for (i=c.begin();i!=c.end();itr++) cout << *i; cout << endl; Output: 0123456789 acegikmoqsuwy AD147 Thanks for any hints in advance Pete
Игорь Микушкин wrote:
Hello!
I wrote the regular expression: ^\s*(?:([A-Za-z_]*)\s*=\s*([A-Za-z0-9_/\.]*)\s*)*$
for splitting lines like: name = abc value1 = def value2 = ghi
I need the result like: match [1] = name match [2] = abc ... match [6] = ghi
But I get ! : match [1] = value2 match [2] = ghi (the last 2 matches)
What is wrong in my expression?
This is normal regular expression behaviour, please see http://www.boost.org/libs/regex/doc/captures.html for an explanation, and possible solution. John.
participants (3)
-
John Maddock
-
Pete
-
Игорь Микушкин