PHP Alphanumeric RegExp with letter from any language
Posted: 30 Dec 2014, 18:54
I am trying to write a Regular Expression that makes sure the characters are all Alpha Numeric, and that accepts other characters as well. I would like to accept letters from other languages: áéíñóúüÁÉÍÑÓÚÜ and @.+-.
To accept all alphanumeric characters, and the symbols @.+-. I use the expression:
Now I want to grab the characters áéíñóúüÁÉÍÑÓÚÜ as well. When I use the expression:
It does not seem to work, could anyone please help?
To accept all alphanumeric characters, and the symbols @.+-. I use the expression:
Code: Select all
if (!preg_match("!^[\w@.-]*$!", $str)) {
echo 'error';
}
Code: Select all
if (!preg_match("/[\wáéíñóúüÁÉÍÑÓÚÜ@.\+-].*/", $str)) {
echo 'error';
}