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.

1.0.0 2025-02-23 08:53 UTC

This package is not auto-updated.

Last update: 2025-05-05 07:59:58 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.
}