28

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

Evan Lévesque
  • 2,801
  • 7
  • 36
  • 60

1 Answers1

47

Use split function that accepts Qt Regular Expression.

QRegExp rx("(\\ |\\,|\\.|\\:|\\t)"); //RegEx for ' ' or ',' or '.' or ':' or '\t'
QStringList query = sometext.split(rx);
cesargastonec
  • 394
  • 5
  • 15
Igor
  • 25,778
  • 27
  • 87
  • 113