I'm trying to find a Regex, that allows printable ASCII chars except - " / \ [ ] : ; | = , + * ? < >
The string length must be 1-25
This will work:
/^[^\\[\]\:\;\|\=\,\/+\*\?<>\"]{1,25}$/
But it will match also non-ASCII chars
I'm trying to find a Regex, that allows printable ASCII chars except - " / \ [ ] : ; | = , + * ? < >
The string length must be 1-25
This will work:
/^[^\\[\]\:\;\|\=\,\/+\*\?<>\"]{1,25}$/
But it will match also non-ASCII chars
You may use
/^(?:(?![:[\];|\\=,\/+*?<>"])[ -~]){1,25}$/
See the regex demo
Details
^
- start of string(?:
- outer grouping to enable matching a quantified lookahead-restricted ASCII char range
(?![:[\];|\\=,\/+*?<>"])
- the next char cannot be one defined in the character class (:
, [
, ]
, ;
, |
, \
, =
, ,
, /
, +
, *
, ?
,
<
, >
and "
)[ -~]
- any printable ASCII){1,25}
- 1 to 25 occurrences$
- end of string