A regular expression that always returns false

Possible duplicate:
Which regular expression will never match?

how to write a regular expression that always returns false in php.

I need this bcos. I wanted to display an error message with an out-of-form rule ... so I liked it ..

if($values['result_msg'] == 'ERROR')
                    {
                    $form->registerRule('just_check','regex','/$^/');                       
                    $form->addRule('abc', 'Please enter valid Model Number.','just_check');
                    }
+3
source share
3 answers

There are many ways to do this:

  • /(?=a)b/

This does not match because it is looking for a character that is both a and b.

  • /\Zx\A/

This does not match, because the end of the line cannot be before the start of the line.

  • /x\by/

This does not match, because the word boundary cannot be between the xand characters y.

+6

, , :

(?!x)x

(?!.. ) - , : ", ", x, x "match x" - , .

, ..

^(?!x)x$

x , , .

, , - . .

+6

Try the following:

$.^
0
source

Source: https://habr.com/ru/post/1762450/


All Articles