Вопрос

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.

Это было полезно?

Решение

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

(?<!\\\\);

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top