is_partial_match


Description:

public bool is_partial_match ()

Usually if the string passed to g_regex_match*() matches as far as it goes, but is too short to match the entire pattern, false is returned.

There are circumstances where it might be helpful to distinguish this case from other cases in which there is no match.

Consider, for example, an application where a human is required to type in data for a field with specific formatting requirements. An example might be a date in the form ddmmmyy, defined by the pattern "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$". If the application sees the user’s keystrokes one by one, and can check that what has been typed so far is potentially valid, it is able to raise an error as soon as a mistake is made.

GRegex supports the concept of partial matching by means of the g_regex_match_partial_soft and g_regex_match_partial_hard flags. When they are used, the return code for match or match_full is, as usual, true for a complete match, false otherwise. But, when these functions return false, you can check if the match was partial calling is_partial_match.

The difference between g_regex_match_partial_soft and g_regex_match_partial_hard is that when a partial match is encountered with g_regex_match_partial_soft, matching continues to search for a possible complete match, while with g_regex_match_partial_hard matching stops at the partial match. When both g_regex_match_partial_soft and g_regex_match_partial_hard are set, the latter takes precedence.

There were formerly some restrictions on the pattern for partial matching. The restrictions no longer apply.

See pcrepartial(3) for more information on partial matching.

Parameters:

this

a MatchInfo structure

Returns:

true if the match was partial, false otherwise