I need a regular expression to match strings that have letters, numbers, spaces and some simple punctuation (.,!"'/$). I have ^[A-Za-z0-9 _]*[A-Za-z0-9][A-Za-z0-9 _]*$ and it works well for alphanumeric and spaces but not punctuation. Help is much appreciated.
I need a regular expression to match strings that have letters, numbers, spaces and
Share
Just add punctuation and other characters inside classes (inside the square brackets):
This matches every string containing spaces, _, alphanumerics, commas, !, ", $, …
Pay attention while adding some special characters, maybe you need to escape them: more info here