Need help with a QRegExp.
-
Hi,
can somebody help me to solve my regex mistake.
I have the following string (and more like that):
NAME=......,Know I want to extract the part between = and ,
in the party between = and , can be any character (but no = or ,)I have tried something like that (I know its terrible):
@[^=][^,]
[^=^,]@Thx.
-
Hi,
This is more a regexp than a Qt problem but:
Do you know exactly the type of characters you will get before and after the = sign ?
Can they be empty ? -
before the =, the characters should normaly be from A to Z.
And after the = they can be every character (by the NAME if they use some cyrillic names) -
Are you sure that using regular expressions here is a good idea? Seems that what you need is a substring beginning at the equals sign and ending just before the last sign.
Use "QString::mid":http://qt-project.org/doc/qt-5.0/qtcore/qstring.html#mid function to get the substring between '=' and ','. To get the position of '=', provided it changes because of different NAMEs, use "QString::indexOf":http://qt-project.org/doc/qt-5.0/qtcore/qstring.html#indexOf function.
The result would look similar to that:
@ QString line = "NAME=........,";
QString part = line.mid(line.indexOf("=") + 1, line.length() - line.indexOf("=") - 1); @ -
thank you,
i will give it a try.