View Full Version : Best way to parse a string
Lele
20th August 2007, 11:41
Hi,
what would you use to parse a string like this:
name:Bob&surname:Smith&city:Dublin
In order to have
Bob
Smith
Dublin
in three separated string?
thanks in advance
marcel
20th August 2007, 11:50
See QString::split().
First you split after "&" and you get "name:xxx" strings, next you split these strings after ":".
regards
Lele
20th August 2007, 11:54
ok, thanks
I though that was a way like using .arg in the opposite way....
:)
like old scanf....
wysota
20th August 2007, 12:33
You can use QRegExp and parenthesis to capture the parts you want but using QString::split is definitely easier in this case.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.