I want to split a QString into parts by using multiple delimiters ,
or #
or |
It seems that QString has regular expression support but what is the correct expression for this case?
I want to split a QString into parts by using multiple delimiters ,
or #
or |
It seems that QString has regular expression support but what is the correct expression for this case?
This must be work:
QString data = "part1,part2#part3|part4";
QRegExp separator("(,|#|\|)");
QStringList list = data.split(separator);
this is wrong my friend, the only difference you should do is the bracket [ ] because the bracket says each character alone
QRegExp separator("[(,|#|\|)]");
Tested with Qt 5.13.0
Thanks, it real works!