[Development] QRegularExpression -- first round of API review
Giuseppe D'Angelo
dangelog at gmail.com
Tue Jan 17 16:54:54 CET 2012
On 17 January 2012 13:10, Charley Bay <charleyb123 at gmail.com> wrote:
>> > 3) Need a couple of better names for partial matching:
>> > - partial match preferring a complete match
>> > - partial match returning whatever match (partial or complete) is found
>> > first
>> >
>> > PCRE uses Soft and Hard respectively (which are quite meaningless to
>> > me).
>>
>> PreferCompleteMatch / PreferFirstMatch?
>
>
> I so very much prefer "generic-to-specific" in names for better
> auto-completion and grouping of like-minded, like:
>
> - PreferMatchComplete
> - PreferMatchFirst
Just to clarify what these match types do (so we can hopefully concur
on good names), I'll recap from my first message in the thread.
--- snip
A partial match happens when, while we're successfully matching a
pattern against a subject, the end of the subject string is reached.
In an ordinary context usually this is a failed match, but there are
use cases in which we'd like instead to be notified about the partial
match found. [...] Note that of course we can get a complete match
while attempting a partial match.
The use cases for this are basically:
* validators: if we have, say, a QRegExpValidator on a QLineEdit, then
while the user is typing, a partial match denotes an "Intermediate"
status of the validator -- the string may become fully Valid when the
user finishes to enter it.
* incremental matching (see T6): in order to scan a big text, we would
like to provide it in chunks to the regexp engine. The obvious problem
is "what if the text that matches the pattern is across 2+ chunks" --
that's where you could use partial matching. A partial match becomes a
way of saying "feed me with more input".
--- snip
The point is that these two use cases require different kinds of
partial matching. A validator should detect a partial match, but a
complete match should be preferred.
Incremental/multisegment matching requires to "prefer partial" if the
pattern could match eventual additional characters beyond the end of
the subject string. For instance, this kind partial matching requires
/(abc)*/ =~ "abc" to report a partial match (although the subject
matched the entire pattern!), because it could match other characters
after the end of the subject.
HTH,
--
Giuseppe D'Angelo
More information about the Development
mailing list