Regular Expression - Negation String + OR

Leandro Papasidero

I need to match string that are not 11111 OR 22222 (EXACT)

<?php
$string = 'STRING'
$pattern = '#PATTER#' // what I have to find
echo preg_match($pattern, $string) ? 'match' : 'no match';

Cases:

$string = '33333';// match

$string = '222222';// match

$string = '11111';// no match

$string = '22222';// no match

I tried many patters that I google and none of them work.

NOTE: It has to be pure REGEX and NOT negating the function preg_match

jrahhali

How about:

 ^(?!11111$|22222$).*

test: https://regex101.com/r/wU7yO0/1

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Related Related

HotTag

Archive