Mar 14, 2011 at 11:39pm UTC
Hi,
I am using Visual Studio 2008, and trying to delimit a string using the split_regex function from the Boost Libraries. I am trying to delimit by [
here is an example of my code
string toDelimit = "/artists/artist[@id=3]/band";
vector <string> elemPredicateList;
boost::algorithm::split_regex(elemPredicateList, toDelimit, regex("["));
I have this nested in a try, catch and always end up in my catch statement.
Any help is greatly appreciated.
Thank you,
May
Mar 14, 2011 at 11:56pm UTC
Escape the '[' character, it is special function character in regular expressions (which means without escaping it, your expression is always invalid and thus causes an error).
Mar 15, 2011 at 12:20am UTC
hanst99, thank you for the reply.
I have just added
boost::algorithm::split_regex(elemPredicateList, toDelimit, regex("\["));
but again it is not being delimited.
any further hints is greatly appreciated..
Thanks again,
May
Mar 15, 2011 at 12:23am UTC
That's because '\' is a special character in C++, so you actually have to escape it as well xD