Regex for only allowing letters, numbers, space, commas, periods?
php, regex
Solution
`^[\.a-zA-Z0-9,!? ]*$`
is what the regex is, it works, see example website to test regex.
Problem
I am clueless with regex as it is complicated for me. I am working with a program that limits input from users based on a regex. I am currently after a regex that will only let the user input: ``` A-Z and a-z 0-9 . , ! ? ``` So basically anything in a typical paragraph or web article. The program states "Enter a regular expression which entered text must match (evaluated with preg_match, using s and i flags) for it to be valid." I have tried this regex with no success and I am currently searching for others to try. ``` '/^[a-zA-Z0-9,.!? ]*$/' ``` It should allow a simple sentence such as "HI my name is John! I like to eat apples, oranges, and grapes. Will you eat with me?