qt-interest@trolltech.com
[Top] [All Lists]

Re: Problem with QRegExp::capturedTexts()

Subject: Re: Problem with QRegExp::capturedTexts()
From: "Caleb Tennis"
Date: Sat, 16 Oct 2004 17:25:54 -0500 EST
> The following code:
>
> QString strMessage ( "ERROR :Closing Link: testclient by
> Ede.NL.EU.UnderNet.Org (Too many connections from your host)" );
> QRegExp regExp ( "^ERROR :Closing Link: (.*) by (.*) (.*)$" );


> Why is "host)" separated from the above line?

Regexps are greedy, so the second (.*) is matching everything up to the
last space (including all spaces in between).  You'll need to be craftier
with your regexp, using \w and \s as necessary instead of .*

I highly recommend using the regexptester program that is included in the
examples subdirectory of Qt so you can check your regexp matches.  Very
helpful.

Caleb

--
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>