Qstring Problem
-
wrote on 18 Mar 2012, 03:28 last edited by
Say i have a Qstring of the following
QString str1 = "HelloWorldThere";
How would i go about extracting the characters from index 2 all the way to index 7 within the string so i can effectively retrieve this sing.
Qstring extractedString = "lloWor";
Pretty much i just want to extract a string from within a string when i have a starting index and an ending index. Any help is greatly appreciated
-
wrote on 18 Mar 2012, 03:41 last edited by
QString y = str1.mid(1, 6);
-
wrote on 18 Mar 2012, 03:44 last edited by
I think QRegExp class can help you:
"QRegExp Class Reference":http://qt-project.org/doc/qt-4.8/qregexp.html
-
wrote on 18 Mar 2012, 19:14 last edited by
QRegExp is worthless for this situation. Please try not to confuse users with random answers that are vaguely related. poporacer suggests the right approach.
-
wrote on 18 Mar 2012, 19:19 last edited by
[quote author="poporacer" date="1332042095"] QString y = str1.mid(1, 6);[/quote]
This is the right approach, but it should be:
@ QString y = str1.mid(2, 6);@
1/5