regex.test

Returns whether Pattern matches anywhere in Text.

Syntax

Signature
regex.test(Text: string, Pattern: string) -> boolean

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
TextstringInput bytes, up to 1 MiB.
PatternstringPCRE2 pattern, up to 16 KiB.

Returns

TypeDescription
booleanTrue 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]+$"))