.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead. .. _class_RegEx: RegEx ===== **Inherits:** :ref:`Reference` **<** :ref:`Object` **Category:** Core Brief Description ----------------- Simple regular expression matcher. Member Functions ---------------- +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`compile` **(** :ref:`String` pattern, :ref:`int` capture=9 **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`find` **(** :ref:`String` text, :ref:`int` start=0, :ref:`int` end=-1 **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** **)** | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_valid` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_capture_count` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_capture` **(** :ref:`int` capture **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_capture_start` **(** :ref:`int` capture **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringArray` | :ref:`get_captures` **(** **)** const | +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ Description ----------- Class for finding text patterns in a string using regular expressions. Regular expressions are a way to define patterns of text to be searched. This class only finds patterns in a string. It can not perform replacements. Usage of regular expressions is too long to be explained here, but Internet is full of tutorials and detailed explanations. Currently supported features: Capturing ``()`` and non-capturing ``(?:)`` groups Any character ``.`` Shorthand character classes ``\w \W \s \S \d \D`` User-defined character classes such as ``:ref:`A-Za-z``` Simple quantifiers ``?``, ``\*`` and ``+`` Range quantifiers ``{x,y}`` Lazy (non-greedy) quantifiers ``\*?`` Beginning ``^`` and end ``$`` anchors Alternation ``|`` Backreferences ``\1`` and ``\g{1}`` POSIX character classes ``:ref:`[:alnum:`]`` Lookahead ``(?=)``, ``(?!)`` and lookbehind ``(?<=)``, ``(?` **compile** **(** :ref:`String` pattern, :ref:`int` capture=9 **)** Compiles and assign the regular expression pattern to use. The limit on the number of capturing groups can be specified or made unlimited if negative. .. _class_RegEx_find: - :ref:`int` **find** **(** :ref:`String` text, :ref:`int` start=0, :ref:`int` end=-1 **)** const This method tries to find the pattern within the string, and returns the position where it was found. It also stores any capturing group (see :ref:`get_capture`) for further retrieval. .. _class_RegEx_clear: - void **clear** **(** **)** This method resets the state of the object, as it was freshly created. Namely, it unassigns the regular expression of this object, and forgets all captures made by the last :ref:`find`. .. _class_RegEx_is_valid: - :ref:`bool` **is_valid** **(** **)** const Returns whether this object has a valid regular expression assigned. .. _class_RegEx_get_capture_count: - :ref:`int` **get_capture_count** **(** **)** const Returns the number of capturing groups. A captured group is the part of a string that matches a part of the pattern delimited by parentheses (unless they are non-capturing parentheses *(?:)*). .. _class_RegEx_get_capture: - :ref:`String` **get_capture** **(** :ref:`int` capture **)** const Returns a captured group. A captured group is the part of a string that matches a part of the pattern delimited by parentheses (unless they are non-capturing parentheses *(?:)*). .. _class_RegEx_get_capture_start: - :ref:`int` **get_capture_start** **(** :ref:`int` capture **)** const .. _class_RegEx_get_captures: - :ref:`StringArray` **get_captures** **(** **)** const Return a list of all the captures made by the regular expression.