regex.test
Returns whether Pattern matches anywhere in Text.
Syntax
Signature
regex.test(Text: string, Pattern: string) -> booleanAliases
This function has no aliases.
Parameters
| Parameter | Type | Description |
|---|---|---|
Text | string | Input bytes, up to 1 MiB. |
Pattern | string | PCRE2 pattern, up to 16 KiB. |
Returns
| Type | Description |
|---|---|
boolean | True when a match was found. |
Notes
Uses byte-oriented PCRE2 matching with the same limits as regex.match. Invalid patterns and matching-limit failures raise errors.
Example
Luau
assert(regex.test("player42", "[0-9]+$"))