GLib.MatchInfo.prototype.is_partial_match

function is_partial_match(): Boolean {
    // Gjs wrapper for g_match_info_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 GLib.Regex.prototype.match or GLib.Regex.prototype.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 GLib.MatchInfo.prototype.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.

Since 2.14

Returns

true if the match was partial, false otherwise