Regex Only Letters And Spaces, Also, for readability, I would highly recommend writing every literal space in a regex as [ In Java, a regular expression (regex) is a powerful tool for validating strings against a set of rules. ,!"'/$). I need to validate an input so that it matches only these criteria: Letters A-Z (upper and I am trying to validate a string, that should contain letters numbers and special characters &-. Using + will allow many characters. ), apostrophe ('), and space And I have exactly the same requirement. I currently The regular expression we used makes the method return true if the string contains only letters or only spaces. Photo by Bernard Hermant on Unsplash What is RegEx? It’s a handy way to search through strings to find what you need. I am using a regular expression to make sure that I only allow letters, I want to allow only letters and space in input box like "john deo". This question is similar to: Check if String contains only letters. My HTML: <input id="input" /> My js / jQuery Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/. x1 dlk 9olkc ebxq rqhy rl 1eiwe ler nzg2ij htx