0

I have a QString like "(ram[3].available@=> 10,2,25 &( cpu.load <> 42,49 |qweds[-1].ee0 ~\"arab lllss\" ) )" and I want to enter white space after each non-alphabetic character (i.e. @ , ~, ( and etc.) then split the string. I tried gSkinner online tool and I found that I need to replace \s*\W with $& to have the white space between special characters and alphanumeric characters. But I don't know how I can implement it in Qt using QregExp and QString.

Basically what I want to do is:

QString smth = "(ram[3].available@=> 10,2,25 &( cpu.load <>   42,49 |qweds[-1].ee0 ~\"arab lllss\" ) )";
Qstring smth2 = smth.replace("\s*\W\", "hereIdunnoWhattoPut");
QStirngList l = smth2.split(" ",QString::SkipEmptyParts);
qDebug() << l;
//( "(" , "ram" , "[" , "3" , "]" , "." , "available" , "@" , "=" , ">" , "10".... )
mrz
  • 1,802
  • 2
  • 21
  • 32
  • 1
    Just forget about regexps: iterate the string, [check](http://qt-project.org/doc/qt-4.8/qchar.html#isLetterOrNumber) if the symbol is alphabetic and act accordingly. – Lol4t0 May 12 '13 at 11:43
  • That seems to solve it, then I need to `insert` a space in the index of char...I'm trying it out. – mrz May 12 '13 at 11:47
  • Yes, and you should update your iterators (position counter) carefully. – Lol4t0 May 12 '13 at 11:49

0 Answers0