samedi 25 avril 2015

PHP preg_match exclude


OK this regex will match string like 2aa, a2, 2aaaaaa, aaaa2, aaa2aaaa, 2222a2222-2222-aaaa... in short, mix of alphanumeric characters in a sequence:

preg_match("/(?:\d+[a-z]|[a-z]+\d)[a-z\d]*/i")

now I want to exclude something but I'm stuck, something like this doesn't work

preg_match("/(?!1920x1200|1920x1080)(?:\d+[a-z]|[a-z]+\d)[a-z\d]*/i")

for example the string aaaaa222aaa1920x1200bbbbb1234556789 is still matched but it shouldn't because it contains 1920x1200

any help is appreciated :)

i'm using regex found here for matching alphanum sequences Regex: only match letters WITH numbers

regex test: http://ift.tt/1GuFyP9


Aucun commentaire:

Enregistrer un commentaire