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

Re: QRegExp minimal match

Subject: Re: QRegExp minimal match
From: Jasmin Blanchette
Date: Tue, 20 Mar 2007 16:13:06 +0100
Hi Bernd,

with setMinimal(true) and the string "abc" I expected the QRegExp "^(.*)(.)?(.)?$" to set the submatches $1=a, $2=b and $3=c.

But it results in $1=abc. Why ?

The minimal matching is "global", i.e. it tries to find the shortest match possible for the entire string. The individual matches within the string are still performed as usual.

I guess this begs the question: Why does't QRegExp support minimal quantifiers, e.g., *? and +?. The short answer is that is very difficult to accomplish with the current regexp engine. In the long term, I'd like us to rewrite the engine (or use a 3rd party engine) so that Qt's regexp support this kind of features and follow some standard (whether it be Perl, JavaScript, POSIX, ...).

Regards,

Jasmin

--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/

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