View Full Version : QReqExp for any number of white spaces
jesse_mark
8th November 2012, 22:37
Hello
any body can help me with a ReqExp for any number of white spaces...
I tried "[//s]" but this match one space. .
I Have a qStringList f.e = " xxxxxx xxxxxx xxxxx xxx xx"
I want to split each word by the spaces
when i tried QSl.splite("")
this give me a QStringList has each word but also has empty Strings.
so how can i have a QStringList with onlyt the words. im tryin to use the white space regexp to split my qstringlist.
thanks
ChrisW67
9th November 2012, 01:37
any body can help me with a ReqExp for any number of white spaces...
I tried "[//s]" but this match one space. .
The regular expression you given will match a single forward slash / or letter s. Did you mean "\\s" perhaps?
I Have a qStringList f.e = " xxxxxx xxxxxx xxxxx xxx xx"
You probably have a QString not a QStringList. A QStringList is what you will get when you split the string. If you do, indeed, have a QStringList then you need to split each string in the list separately.
I want to split each word by the spaces
when i tried QSl.splite("")
Neither QStringList nor QString has a splite() function. Did you mean QString::split() perhaps? Did you also mean to put a space between the quotes?
this give me a QStringList has each word but also has empty Strings.
Yes, that is what you asked it for. QString::split() has more than one argument, and one of them is obviously useful in this situation.
so how can i have a QStringList with onlyt the words. im tryin to use the white space regexp to split my qstringlist.
You do not need a regular expression to do this but: "\\s+" will match one or more whitepaces.
jesse_mark
9th November 2012, 15:33
Thanks you so much for taking time and replying to me with details helped me really.
The regular expression you given will match a single forward slash / or letter s. Did you mean "\\s" perhaps?
Yes, i did mean "\\s"
You probably have a QString not a QStringList. A QStringList is what you will get when you split the string. If you do, indeed, have a QStringList then you need to split each string in the list separately.
Yes, you are completely right, I do have QStringList and i need to split each string in the list separately .
Neither QStringList nor QString has a splite() function. Did you mean QString::split() perhaps? Did you also mean to put a space between the quotes?
I think QString does has the Spilt() function becuz this what i use... MyQstring.split("space") ..... yes i did put space between the quotes, but i don't know why the editor eats all the spaces.
Yes, that is what you asked it for. QString::split() has more than one argument, and one of them is obviously useful in this situation.
Yes this what i asked for, but i dont want it to keep the empty strings, but thank i looked again to the other arguments the split has and i there are three
1 - the qstring or the reqexp
2- Split behavior , which has a default value KeepEmptyParts .. << this what i need to change
3: Case sensitivity which also has a default value Qt::CaseSensitive
You do not need a regular expression to do this but: "\\s+" will match one or more whitepaces.
I want to use the Qstring.split(QRegExp("\\s+")); to split the each word of the string and create a list.
what other way can i use to do that with out using the regular expression ??
Thank you again :)
amleto
9th November 2012, 19:35
qstring.html#split
ChrisW67
10th November 2012, 06:15
2- Split behavior , which has a default value KeepEmptyParts .. << this what i need to change
So change it.
what other way can i use to do that with out using the regular expression ??
See above
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.