0

I'm trying to split a string by using ; as delimiter but not when it is escaped \;. The string can contain characters, numbers, and nested quotes. I'm currently using boost::algorithm::split_regex like so:

string data = "hello; world; 100444; \"Hello \\; world\";";
vector<string> data_vec;

boost::algorithm::split_regex( data_vec, data, boost::regex("[^\\\\];");

I have tried to use negation but that didn't have any effect. boost::regex("(?:[^\\\\]);")

Any suggestions? Thank you in advance.

kendotwill
  • 1,892
  • 18
  • 17

1 Answers1

2

You'll want to use negative lookbehind (?<!regex) like this

(?<!\\\\);

anthonyvd
  • 7,329
  • 4
  • 30
  • 51