If i have a QString in the form of QString s = QString("A:B[1:2]:C:D");
i want somehow to split by ':'
, but only, if not enclosed in square-brackets.
So the desited output of the above QString
woud be "A", "B[1:2]", "C", "D"
Right now, I can only think of something like replacing ':'
in the range of s.indexOf('[')
and s.indexOf(']')
, then split and afterwards replace back to ':'
in any remaining split, but that seems rather inconvenient.
EDIT: based on comments and answers: any number in square-brackets shall be the same after splitting. There are characters, e.g.: ';' that i can use t as temporary replacement for ':'
Any better idea?