regex - PHP preg_match to catch all but some options -


what regex need use achieve following;

check if string not contain 1 or more options... tried lot expressions. think closest correct one.

/^[^(256k)]$|^[^(2m)]$/ 

i preg_match tell me if there other 256k or 2m, , cant negate preg_match (!preg_match) reasons take long explain ;)

you can not place whole words or capturing groups inside of character classes. character class matches one character set of characters.

your regular expression matches beginning of string, character except: (, 2, 5, 6, k, ), followed end of string, or beginning of string, character except: (, 2, m, ), followed end of string.

i believe wanting negative lookahead here instead.

/^((?!256k|2m).)*$/i 

regular expression:

^               # beginning of string (               # group , capture \1 (0 or more times) (?!             # ahead see if there not:   256k          # '256k'  |              # or   2m            # '2m' )               # end of look-ahead .               # character except \n )*              # end of \1  $               # before optional \n, , end of string 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -