I know this seems a common question, but can't get rid of my problem dispite searching. I need a regex that matchs only string that doesn't start with a specified set of words and surrounded by /. Example:
/harry/white
/sebastian/red
/tom/black
/tomas/green
I don't want strings starting with /harry/ and /tom/, so I expect
/harry/white NO
/sebastian/red YES
/tom/black NO
/tomas/green YES
1) ^/(?!(harry|tom)).* doesn't match /tomas/green
2) ^/(?!(harry|tom))/.* matchs nothing
3) ^/((harry|tom))/.* matchs the opposite
What is the right regex? I'd appreciate much if someone explain me why 1 and 2 are wrong. Please don't blame me :) Thanks.
/like/sebastian/red/