How Can I Split a String According To Delimiters in Qt?

I am trying to split a string according to delimiter the equevelant code in C# is :

char[] delimiterChars = { ' ', ',', '.', ':', '\t' }; String[] query = sometext.Split(delimiterChars);

but I want to do it in Qt

-------------Problems Reply------------

Use split function that accepts Qt Regular Expression.

QRegExp rx("(\\ |\\,|\\.|\\:|\\t)"); //RegEx for ' ' or ',' or '.' or ':' or '\t'
QStringList query = sometext.split(rx);

I think that old ubiquitous strtok or strtok_r is what you are looking for

If you really want to do this the QT native what take a look at the split function in QString Class:

This link provides a good example for the use. The difference is that it doesn't allow for multiple delimiter characters in the sep string. It actually takes the exact string you pass as separator.

Category:qt Views:7 Time:2011-12-20

Related post

Copyright (C), All Rights Reserved.

processed in 0.158 (s). 11 q(s)