I want to make a regex, that matches letters from all alphabets and special characters, and ignores symbols like ✪❀✱↴♜
and so on.
My regular expression looks like:
/^([\p{L}0-9~!@#$%^&*_\-+='|{}\(\)\[\]:;"<>,.?\/\\\s])+$/i
.
Problem is - it works perfectly in regex online tester, but somehow fails in PHP code for non latin strings like ǺǻαάǠẮắẰằẳẴẵĪäÅÀÁÂåãâàáÃᗩ
:
$text = 'ǺǻαάǠẮắẰằẳẴẵĪäÅÀÁÂåãâàáÃᗩ';
if(preg_match("/^([\p{L}0-9~!@#$%^&*_\-+='|{}\(\)\[\]:;\"<>,.?\/\\\s])+$/i", $text)){
echo 'success';
} else {
echo 'fail';
}
I have also tried another regex: /[\p{L}0-9~!@#$%^&*_\-+='|{}\(\)\[\]:;"<>,.?\/\\\s]+/i
. It also works fine in regex tester, but in preg match function it matches almost everything. Does anyone know why those regular expressions behave so in preg_match function?