I am trying to get this Regex to work to validate a Name field to only allow A-Z, \' and -.
So far I am using this which is working fine apart from it wont allow an
From what I see. Following Regex should work fine:
if (preg_match("/^[A-Z\'\-]+$/",$firstname)) { // do something }
Here I have escaped both apostrophe and dash. I have tested this in an online Regex tester and works just fine.
Give it a try