In my code, I use a regexp I googled somewhere, but I don’t understand it. 🙂
preg_match("/^[\p{L} 0-9\-]{4,25}$/", $login))
What does that p{L} mean? I know what it does — all characters with national letters included.
And my second question, I want to sanitize user input for ingame chat, so I’m starting with the regexp mentioned above, but I want to allow most special characters. What’s the shortest way to do it? Has someone already prepared a regexp to do it?
For \p see Unicode character properties basically it require the character to be in a specific character class (Letter, number, …).
For your filter it depends on what exactly you want to filter but looking at Unicode character classes is the good way to go i think (adding individually any character that seem useful to you).