if ( preg_match('/\^[p{Letter}\s]+$/u', $tagstring) == 0 ){
$this->validation->set_message('_check_valid_tags', 'Tags must contain only leters from any language');
return FALSE;
}
I'm trying to match a string only with spaces and letters. Letters can be in any language.
What's wrong with my regex? Or with any other trouble source.
A couple of things:
- long property names as \p{Letter} are not supported by PHP's regex engine. You can use \p{L} intsead.
- you don't need to escape the beginning of the string character: ^, if you do, it would just match the character '^'
- if the strings can become large, you could speed things up by making the greedy '+' possessive by putting an extra '+' after it