How can I match all the “special” chars (like +_*&^%$#@!~
) except the char -
in PHP?
I know that \W
will match all the “special” chars including the -
.
Any suggestions in consideration of Unicode letters?
[^-]
is not the special character you want[\W]
are all special characters as you know[^\w]
are all special characters as well - sounds fair?So therefore [^\w-]
is the combination of both: All "special" characters but without -
.