Hi,
I'm trying to write a regular expression to check if someone has inputted a valid name for themselves. I started off by just making sure they had entered a-z or A-Z or spaces. But I quickly realised that there are names like O'Brian and those names with the funny accent over the 'e' and the 'o'.
I wondered if someone has a regular expression that they use to check for valid names?
Here's what I've got so far... (bear in mind I'm absolutely useless at regex's and this was through a lot of trial and error!)
function check_valid_name($string) {
return preg_match("%[^a-zA-Z\-\\'\\\ ]%", $string);
}
Many thanks for any help you can give me
Cheers
John ;-)
I don't make mistakes, I'm merely beta-testing life.
I'm trying to write a regular expression to check if someone has inputted a valid name for themselves. I started off by just making sure they had entered a-z or A-Z or spaces. But I quickly realised that there are names like O'Brian and those names with the funny accent over the 'e' and the 'o'.
I wondered if someone has a regular expression that they use to check for valid names?
Here's what I've got so far... (bear in mind I'm absolutely useless at regex's and this was through a lot of trial and error!)
function check_valid_name($string) {
return preg_match("%[^a-zA-Z\-\\'\\\ ]%", $string);
}
Many thanks for any help you can give me
Cheers
John ;-)
I don't make mistakes, I'm merely beta-testing life.