Regular expressionsReference
Regex.Escape
Escape text for a literal match in a regex pattern.
Details#
Escape text for a literal match in a regex pattern. String with regex metacharacters escaped using a backslash.
Signature#
Regex.Escape(text: string): stringParameters#
| Parameter | Type | Description |
|---|---|---|
text | string | Literal text to include in a regex. |
Returns#
String with regex metacharacters escaped using a backslash.
Examples#
Local example
local pattern = Regex.new(Regex.Escape("notes.txt"))
print(pattern:Match("open notes.txt")) -- notes.txt