Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, March 2002
QRegExp Problem


Message 1 in thread

Hi all QT experts,

I have this example String:

msg = "(<4>)(-<5>)"

so I tried to filter the strings between the ( ) like this,

QStringList part = StringList:.split(QRegExp("(*)"), msg);

my expected List would be:
<4>
-<5>

but I get this:

(<4>
(-<5>

I like to do the same with the < > after I have filtered the strings inside
the ( )

what expression do I have to use?

thx andy


Message 2 in thread

You are not using regular expressions correctly.  Regular expressions are
_not_ the same as filename globs. Use the following to split on the ')'
and '(' correctly:

QStringList part = StringList:.split(QRegExp("[()]"), msg);


On Mon, 4 Mar 2002, Ebner Andreas VA Mechatronics wrote:

> Hi all QT experts,
>
> I have this example String:
>
> msg = "(<4>)(-<5>)"
>
> so I tried to filter the strings between the ( ) like this,
>
> QStringList part = StringList:.split(QRegExp("(*)"), msg);
>
> my expected List would be:
> <4>
> -<5>
>
> but I get this:
>
> (<4>
> (-<5>
>
> I like to do the same with the < > after I have filtered the strings inside
> the ( )
>
> what expression do I have to use?
>
> thx andy
>
> --
> List archive and information: http://qt-interest.trolltech.com
>