Regex

class Regex(*args, **kwargs)
Constructors:

new_for_match(pattern:str, pattern_length:int, flags:int) -> Vte.Regex
new_for_search(pattern:str, pattern_length:int, flags:int) -> Vte.Regex

Constructors

class Regex
classmethod new_for_match(pattern: str, pattern_length: int, flags: int) Regex

Compiles pattern into a regex for use as a match regex with 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 <literal>PCRE2_UTF</literal> and possibly other flags, in addition to the flags supplied in flags.

Parameters:
  • pattern – a regex pattern string

  • pattern_length – the length of pattern in bytes, or -1 if the string is NUL-terminated and the length is unknown

  • flags – PCRE2 compile flags

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

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

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

Parameters:
  • pattern – a regex pattern string

  • pattern_length – the length of pattern in bytes, or -1 if the string is NUL-terminated and the length is unknown

  • flags – PCRE2 compile flags

Methods

class Regex
jit(flags: int) bool

If the platform supports JITing, JIT compiles regex.

Parameters:

flags – PCRE2 JIT flags, or 0

substitute(subject: str, replacement: str, flags: int) str

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

Added in version 0.56.

Parameters:
  • subject – the subject string

  • replacement – the replacement string

  • flags – PCRE2 match flags