I need an regex to my preg_match(), it should preg (allow) the following characters:
String can contain only letters, numbers, and the following punctuation marks:
- full stop (.)
- comma (,)
- dash (-)
- underscore (_)
I have no idea , how it can be done on regex, but I think there is a way!
will match a string that contains only (Unicode) letters, digits or the “special characters” you mentioned.
[...]is a character class, meaning “one of the characters contained here”. You’ll need to use the/uUnicode modifier for this to work:If you only care about ASCII letters, it’s easier:
or, in PHP: