kendotwill
kendotwill

Reputation: 2020

Split string using boost::algorithm::split_regex

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.

Upvotes: 0

Views: 3096

Answers (1)

anthonyvd
anthonyvd

Reputation: 7590

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

(?<!\\\\);

Upvotes: 2

Related Questions