Hi,
I'm really new to regex's and wondered if you could just double check these for me. The first two are working (appear to be) the last one isn't.
function check_only_alphabet($string) {
// THIS SHOULD ONLY ALLOW a-z, A-Z and spaces - it seems to be working
return preg_match('%[^a-zA-Z *]%', $string);
}
function check_legal_characters($string) {
// THIS SHOULD ONLY ALLOW EVERYTHING ABOVE PLUS 0-9 - it seems to be working
return preg_match('%[^a-zA-Z0-9 *]%', $string);
}
function check_legal_description($string) {
// THIS SHOULD ALLOW EVERYTHING FROM ABOVE AND '.,:; - IT DOESN'T ALLOW ' ANY IDEAS WHY NOT?
return preg_match("%[^a-zA-Z0-9\'.,:; *]%", $string);
}
Many thanks for any light you can shed on this
Cheers
John ;-)
I don't make mistakes, I'm merely beta-testing life.
I'm really new to regex's and wondered if you could just double check these for me. The first two are working (appear to be) the last one isn't.
function check_only_alphabet($string) {
// THIS SHOULD ONLY ALLOW a-z, A-Z and spaces - it seems to be working
return preg_match('%[^a-zA-Z *]%', $string);
}
function check_legal_characters($string) {
// THIS SHOULD ONLY ALLOW EVERYTHING ABOVE PLUS 0-9 - it seems to be working
return preg_match('%[^a-zA-Z0-9 *]%', $string);
}
function check_legal_description($string) {
// THIS SHOULD ALLOW EVERYTHING FROM ABOVE AND '.,:; - IT DOESN'T ALLOW ' ANY IDEAS WHY NOT?
return preg_match("%[^a-zA-Z0-9\'.,:; *]%", $string);
}
Many thanks for any light you can shed on this
Cheers
John ;-)
I don't make mistakes, I'm merely beta-testing life.