tribe_is_regex( string $candidate )

Checks whether a candidate string is a valid regular expression or not.


Parameters

$candidate

(string) (Required) The candidate string to check, it must include the regular expression opening and closing tags to validate.


Top ↑

Return

(bool) Whether a candidate string is a valid regular expression or not.


Top ↑

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;
		}
	}

Top ↑

Changelog

Changelog
Version Description
4.9.5 Introduced.