boost split_regex delimit by "["

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
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).
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
That's because '\' is a special character in C++, so you actually have to escape it as well xD
Topic archived. No new replies allowed.