PDA

View Full Version : I've found but how to use



Laser
8th August 2008, 14:07
The regular expression I've found by the position it starts can be any length long.
What is the convinient way to get it all into a string? It's starting position in the mother string is not enough knowlege, you see.

I.m working with QFile QTextStream QRegExp objects.
Probably another tech should be used or can you open my eyes on methods I've missed?

jpn
8th August 2008, 14:21
See QRegExp::matchedLength().

Laser
11th August 2008, 08:48
Thank you JPN. It helps:
see regexp1.png

Now experiencing problems while splitting the founded expression(number1 / number2 into QStringList "number1" , "number2" ) using Qstring str.split(" \ / ") code line:
see regexp10.png.

Probably, I' ve made a mistake, but
I can not retrieve correct results from help code example also:
http://doc.trolltech.com/4.4/qregexp.html#capturedTexts :
see regexp2.png

How can it be possible to cut founded end extracted( thks to JPN) regular expression into
QStringList by

Qstring str.split(..)

or

Qregexp rx;
QStringList rx.capturedTexts();

or any other way?

spirit
11th August 2008, 09:24
that code works


qDebug() << QString("number1 / number2").split(" / "); //("number1", "number2")

or I didn't understand something?

Laser
11th August 2008, 12:24
You are right. It works. I couldn't see it becouse hadn't iterated through returned QStringList object properly.

You Returned it to... QDebug(). What is it and waht you could see then ?

spirit
11th August 2008, 13:52
the result of this code is
("number1", "number2")
in your case


QStringList result = QString("number1 / number2").split(" / ");