tribe_is_regex( string $candidate )
Checks whether a candidate string is a valid regular expression or not.
Contents
Parameters
- $candidate
-
(string) (Required) The candidate string to check, it must include the regular expression opening and closing tags to validate.
Return
(bool) Whether a candidate string is a valid regular expression or not.
Source
File: src/functions/utils.php
function tribe_is_regex( $candidate ) { if ( ! is_string( $candidate ) ) { return false; } // We need to have the Try/Catch for Warnings too try { return ! ( @preg_match( $candidate, null ) === false ); } catch ( Exception $e ) { return false; } }
Changelog
Version | Description |
---|---|
4.9.5 | Introduced. |