I am very new to regex and JavaScript.
I need a regex for validate only alphanumeric characters and full stop (.), comma(,), colon(:), and semicolon(;).
I am very new to regex and JavaScript.
I need a regex for validate only alphanumeric characters and full stop (.), comma(,), colon(:), and semicolon(;).
If you want to verify that the complete line contains only the allowed characters:
var regexp = new RegExp(/^[a-zA-Z0-9.,:;]+$/);
^
matches at the beginning of the line
[]
matches one of the surrounded characters
+
makes the previous element one or more times
$
matches the end of the line
If the string is allowed to be empty, then turn the +
into a *