Regex "does not start with XX"

Solved
zoipod Posted messages 2 Registration date   Status Membre Last intervention   -  
zoipod Posted messages 2 Registration date   Status Membre Last intervention   -
Hello,

I want to set up a regex using preg_match that would return true if a variable DOES NOT start with a word (not just a single letter)

I'm not an expert in regex, I've heard about assertions but they seem too complex for me..

Important thing: I must do it with a regex (using strpos would have been done already.. but I can't.. The preg_match is already present in a script, and the regex has to be stored in the database)

Thank you.

2 réponses

jordane45 Posted messages 30426 Registration date   Status Modérateur Last intervention   4 830
 
Hello,

Wouldn't something like this do the trick?:

^(?!YourWord).*


--
Best regards,
Jordane
8
zoipod Posted messages 2 Registration date   Status Membre Last intervention  
 
Indeed, quite simply.

My final regex is:
^(?!AN)^(?!AM)

(Does not start with AN or AM)

Thank you very much!
0