Need help with REGEX expression ( boost::regex_search )

Hi ! I work with Visual Studio 2003, C++. I am reading data from a UNICODE file in a std::wstring. (It works fine) I want to find with boost::regex_search a pattern like the following: @@FOREACH(item in list) data @@END I want 3 substrings (submatch) like the following: 1- item 2- list 3- data We can have line feed, carriage return, space, etc. between ( and item, between ) and the data, and between data and @@END. So the following must work: @@FOREACH( item in list ) data @@END I DID MANY THINGS (TRY AND ERROR) AND I CAN FIND the first submatch item and the second submatch list. The third submatch never works. It don't see the @@END command (instruction) and get all the remaining stuff of the string. I used Regex Coach software and Rad Regex Designer but with theses softwares, my REGEX expression works. What is the correct REGEX expression with BOOST ???? Thank you ! :-( -- View this message in context: http://www.nabble.com/Need-help-with-REGEX-expression-%28-boost%3A%3Aregex_s... Sent from the Boost - Dev mailing list archive at Nabble.com.

Danny Gilbert wrote:
Hi ! I work with Visual Studio 2003, C++. I am reading data from a UNICODE file in a std::wstring. (It works fine) I want to find with boost::regex_search a pattern like the following:
@@FOREACH(item in list) data @@END
I want 3 substrings (submatch) like the following: 1- item 2- list 3- data We can have line feed, carriage return, space, etc. between ( and item, between ) and the data, and between data and @@END.
So the following must work: @@FOREACH( item in list ) data @@END
I DID MANY THINGS (TRY AND ERROR) AND I CAN FIND the first submatch item and the second submatch list. The third submatch never works. It don't see the @@END command (instruction) and get all the remaining stuff of the string. I used Regex Coach software and Rad Regex Designer but with theses softwares, my REGEX expression works.
What is the correct REGEX expression with BOOST ????
Well the same as for any other regex package! Off the top of my head, how about something like: "@@FOREACH\\(\\s*(\\S+)\\s+in\\s+([^)]*?)\\s*\\)\\s*(.*?)\\s*@@END" HTH, John.
participants (2)
-
Danny Gilbert
-
John Maddock