MailPoet\EmailEditor\Validator
Schema::validate_pattern()
Validates the regular expression pattern.
Method of the class: Schema{}
No Hooks.
Return
null
. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->validate_pattern( $pattern ): void;
- $pattern(string) (required)
- Regular expression pattern.
Schema::validate_pattern() Schema::validate pattern code WC 9.8.1
protected function validate_pattern( string $pattern ): void { $escaped = str_replace( '#', '\\#', $pattern ); $regex = "#$escaped#u"; if ( @preg_match( $regex, '' ) === false ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged throw new \Exception( \esc_html( "Invalid regular expression '$regex'" ) ); } }