Vte.Regex

Fields

None

Methods

class

new_for_match (pattern, pattern_length, flags)

class

new_for_match_full (pattern, pattern_length, flags, extra_flags)

class

new_for_search (pattern, pattern_length, flags)

class

new_for_search_full (pattern, pattern_length, flags, extra_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, and man:pcre2api(3) for information about the supported flags.

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

classmethod new_for_match_full(pattern, pattern_length, flags, extra_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

  • extra_flags (int) – PCRE2 extra compile flags

Raises:

GLib.Error

Returns:

a newly created Vte.Regex, or None

error_offset:

return location to store the error offset

Return type:

(Vte.Regex, error_offset: int)

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, and man:pcre2api(3) for information about the supported flags and extra_flags.

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

If regex compilation fails, error will be set and error_offset point to error as an offset into pattern.

New in version 0.76.

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, and man:pcre2api(3) for information about the supported flags.

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

classmethod new_for_search_full(pattern, pattern_length, flags, extra_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

  • extra_flags (int) –

Raises:

GLib.Error

Returns:

a newly created Vte.Regex, or None

error_offset:

return location to store the error offset

Return type:

(Vte.Regex, error_offset: int)

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, and man:pcre2api(3) for information about the supported flags and extra_flags.

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

If regex compilation fails, error will be set and error_offset point to error as an offset into pattern.

New in version 0.76.

jit(flags)
Parameters:

flags (int) – PCRE2 JIT flags, or 0

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) and man:pcre2_substitute(3) 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.