Regular expressionsReference
Regex.new
Compile an ECMAScript regular expression.
Details#
Compile an ECMAScript regular expression. A Regex object with Match, MatchMany and Replace methods. Invalid patterns raise an error.
Signature#
Regex.new(pattern: string): RegexParameters#
| Parameter | Type | Description |
|---|---|---|
pattern | string | ECMAScript regex pattern; this is not Lua pattern syntax. |
Returns#
A Regex object with Match, MatchMany and Replace methods. Invalid patterns raise an error.
Examples#
Local example
local digits = Regex.new("[0-9]+")
print(digits:Match("item 42")) -- 42