mawebdk / preg-match
PregMatch is an encapsulation of preg_match returning a boolean instead of 0/1 and throwing an exception in case of an error.
Installs: 7
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/mawebdk/preg-match
Requires
- php: ^8.3.6
Requires (Dev)
- phpunit/phpunit: ^12.0.2
This package is not auto-updated.
Last update: 2025-10-20 10:03:31 UTC
README
PregMatch is an encapsulation of preg_match returning a boolean instead of 0/1 and throwing an instance of PregMatchException in case of an error.
The parameters for PregMatch::pregMatch() behaves the same as the parameters for PHP's built-in function preg_match() except for the absence of the parameters "flags" and "offset".
Usage
try {
if (PregMatch::pregMatch($pattern, $subject, $matches)):
// Code in case on a matched regular expression.
else:
// Code in case on a non-matched regular expression.
endif;
} catch (PregMatchException $e) {
// Error handling.
}