Vte.Regex

Fields

None

Methods

class new_for_match (pattern, pattern_length, flags)
class new_for_search (pattern, pattern_length, flags)
  jit (flags)
  ref ()
  substitute (subject, replacement, flags)
  unref ()

Details

class Vte.Regex
classmethod new_for_match(pattern, pattern_length, flags)
Parameters:
  • pattern (str) – a regex pattern string
  • pattern_length (int) – the length of pattern in bytes, or -1 if the string is NUL-terminated and the length is unknown
  • flags (int) – PCRE2 compile flags
Raises:

GLib.Error

Returns:

a newly created Vte.Regex, or None with error filled in

Return type:

Vte.Regex

Compiles pattern into a regex for use as a match regex with Vte.Terminal.match_add_regex() or Vte.Terminal.event_check_regex_simple().

See man:pcre2pattern(3) for information about the supported regex language.

The regex will be compiled using %PCRE2_UTF and possibly other flags, in addition to the flags supplied in flags.

Parameters:
  • pattern (str) – a regex pattern string
  • pattern_length (int) – the length of pattern in bytes, or -1 if the string is NUL-terminated and the length is unknown
  • flags (int) – PCRE2 compile flags
Raises:

GLib.Error

Returns:

a newly created Vte.Regex, or None with error filled in

Return type:

Vte.Regex

Compiles pattern into a regex for use as a search regex with Vte.Terminal.search_set_regex().

See man:pcre2pattern(3) for information about the supported regex language.

The regex will be compiled using %PCRE2_UTF and possibly other flags, in addition to the flags supplied in flags.

jit(flags)
Parameters:flags (int) –
Raises:GLib.Error
Returns:True if JITing succeeded (or PCRE2 was built without JIT support), or False with error filled in
Return type:bool

If the platform supports JITing, JIT compiles self.

ref()
Returns:self
Return type:Vte.Regex

Increases the reference count of self by one.

substitute(subject, replacement, flags)
Parameters:
  • subject (str) – the subject string
  • replacement (str) – the replacement string
  • flags (int) – PCRE2 match flags
Raises:

GLib.Error

Returns:

the substituted string, or None if an error occurred

Return type:

str

See man:pcre2api(3) on pcre2_substitute() for more information.

New in version 0.56.

unref()
Returns:None
Return type:Vte.Regex

Decreases the reference count of self by one, and frees self if the refcount reaches zero.