[..]
is a character set, and will match any single character given it is in the set. If you want to match a while string, then you need repetition *
will match zero or more and +
will match one or more. Since you want to match the entire string you also need to anchor your expression, you can do this with ^
for start of string and $
for end of string.
So the following regex will match star of string
one or more characters from the given set
end of string
:
^[A-Za-z0-9$-/:-?@#{-~!^_\'\[\] *]+$
If you are interested in learning about regex you might want to read up on the basics there are lots of sites with tons of information, such as this one.