29

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
  • 3,115
  • 7
  • 40
  • 61

1 Answers1

48

Use split function that accepts Qt Regular Expression.

QRegExp rx("(\\ |\\,|\\.|\\:|\\t)"); //RegEx for ' ' or ',' or '.' or ':' or '\t'
QStringList query = sometext.split(rx);
cesargastonec
  • 430
  • 7
  • 15
Igor
  • 26,650
  • 27
  • 89
  • 114