Create a new regular expression.
This function can be used to create a regular expression from a given pattern with optional flags.
This function does not generate a change.
regex(pattern, [flags])
Argument | Type | Description |
---|---|---|
pattern | str (required) | The pattern to use as a regular expression. |
flags | str (optional) | Optional flags, see the regex for more information. |
A new regular expression.
Returns a new regular expression from a pattern.
// match strings which start with "the ", case in-sensitive (`i` flag)
re = regex("^the\s", "i");
re.test("The Pretenders");
Example return value in JSON format
true