Skip to content

Regular Expressions

Functions for using regular expressions to manipulate strings.

Authors and contributors to this experimental extension: Add00.


Conditions, actions and expressions to use regular expressions with strings, such as:

  • Find the position of pattern in a string
  • Find a pattern in a string
  • Split a string by a pattern
  • Check if a string matches a pattern
  • Replace patterns in a string with another string

Tip

Learn how to install new extensions by following a step-by-step guide.

Actions

Find all matches for a regex pattern
Builds an array containing all matches for a regex pattern.

See parameters
  • Parameter 1 (string): Pattern
  • Parameter 2 (string): RegEx flags
  • Parameter 3: string
  • Parameter 4 (string): The name of the variable to store the result in

Technical note: parameters 0, 5 are internal parameters handled by GDevelop.

Find all matches with their groups for a regex pattern
Builds an array containing for each regex pattern match an array with the match followed by its regex groups.

See parameters
  • Parameter 1 (string): Pattern
  • Parameter 2 (string): RegEx flags
  • Parameter 3: string
  • Parameter 4 (string): The name of the variable to store the result in

Technical note: parameters 0, 5 are internal parameters handled by GDevelop.

Find first match with groups for a regex pattern
Builds an array containing the first match for a regex pattern followed by the regex groups.

See parameters
  • Parameter 1 (string): Pattern
  • Parameter 2 (string): Flags
  • Parameter 3: string
  • Parameter 4 (string): Variable name

Technical note: parameters 0, 5 are internal parameters handled by GDevelop.

Split a string into an array
Split a string by each part of it that matches a regex pattern and stores each part into an array.

See parameters
  • Parameter 1 (string): The pattern to split by
  • Parameter 2 (string): RegEx flags
  • Parameter 3 (string): The string to split by the pattern
  • Parameter 4 (string): The name of the variable to store the result in

Technical note: parameters 0, 5 are internal parameters handled by GDevelop.

Conditions

String matches regex pattern
Checks if a string matches a regex pattern.

See parameters
  • Parameter 1 (string): The pattern to check for
  • Parameter 2 (string): RegEx flags
  • Parameter 3 (string): The string to check for a pattern

Technical note: parameters 0, 4 are internal parameters handled by GDevelop.

Expressions

Expression Description
RegEx::Find(string, string, string) Finds a regex pattern in a string, and returns the index of the position of the match, or -1 if it doesn't match the pattern.
string Pattern
string RegEx flags
string String
RegEx::Replace(string, string, string, string) Replaces a part of a string that matches a regex pattern with another string.
string The pattern to check for
string RegEx flags
string The string to search for pattern matches in
string The string to replace the matching patterns with

This page is an auto-generated reference page about the Regular Expressions extension, made by the community of GDevelop, the open-source, cross-platform game engine designed for everyone. Learn more about all GDevelop community-made extensions here.