So I am trying to use the following regex in an HTML input:
<input ... pattern="^[a-zA-Z0-9\-.,&?!@#~\';+_ ]+$" ... >
Yes, it's a pretty basic way of setting up a whitelist, and yes, it isn't exactly pretty to look at. However, at the very least it works on regex101.com, so I figured it would be fine to use. Unfortunately, I get the following error:
Pattern attribute value ^[a-zA-Z0-9-.,&?!@#~\';+_ ]+$ is not a valid regular expression: Uncaught SyntaxError: Invalid regular expression: /^[a-zA-Z0-9-.,&?!@#~\';+_ ]+$/: Invalid escape
How am I able to check so that what is acceptable on a website like regex101.com matches what is acceptable in an HTML page?