Skip to content
docsv0.17.0

RegexPattern

A validated regular expression: it cannot exist unless it compiles. `fromRaw` is the only way to build one, so an uncompilable pattern is rejected at construction (a schema error), never at match time. `matches` distinguishes a genuine non-match from an engine failure (backtrack/recursion limit) — the latter is a RegexExecutionException, never a user-facing pattern_mismatch.

RegexPattern::fromRaw()

public static function fromRaw(string $pattern): self

Builds a RegexPattern from a raw string, throwing InvalidSchemaException if it does not compile.

Parameters

Parameters of fromRaw()
NameTypeDescription
$patternstring

RegexPattern::matches()

public function matches(string $value): bool

Tests whether the value matches, throwing RegexExecutionException on an engine failure.

Parameters

Parameters of matches()
NameTypeDescription
$valuestring