Here is my regular expression . I want to include single quotes (') within the characters such as (O'Neal Nickel). Here is my regular expression allowing letters and spaces and full stops(.) and (-) hyphens
/^[A-Za-z\/\s\.-]+$/;
Try putting a backslash ( \ ) followed by " .
$ means "Match the end of the string" (the position after the last character in the string). Both are called anchors and ensure that the entire string is matched instead of just a substring.
Match any specific character in a setUse square brackets [] to match any characters in a set. Use \w to match any single alphanumeric character: 0-9 , a-z , A-Z , and _ (underscore). Use \d to match any single digit. Use \s to match any single whitespace character.
/^[A-Za-z\/\s\.'-]+$/;
Or did I get your question wrong?
Try this:
/^[A-Za-z\/\s\.'\-]+$/;
You do not need to backslash/escape the single quote. Doing so will cause Safari to disallow single quote marks instead of allowing them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With