Regex. Escape Synchronous
Quote literal text so it can be included in a regex without interpreting its punctuation as pattern syntax. Use it when literal user input becomes part of a larger pattern. Characters such as dots and brackets then match themselves instead of acting as regex operators.
Luau
Regex.Escape(text: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
text | string | Literal text to match. |
Returns
stringA regex fragment that matches the supplied text literally.
Example
Luau
local literal = Regex.new(Regex.Escape("settings.json"))
print(literal:Match("open settings.json")) -- settings.json