I have a regex that matches all ascii characters:
/^[\x00-\x7F]*$/
Now I need to exclude the following characters from this range: ', ". How to do it?
'
"
You can use a negative result for forbidden characters:
/^((?!['"])[\x00-\x7F])*$/
RegEx Demo
(?!['"]) - negative lookahead to forbid single / double quotes in your input.
(?!['"])
You can exclude characters from the range by doing
/^(?![\.])[\x00-\x7F]*$/
prefix c (?![\.])to exclude .regular expressions from matching.
(?![\.])
.
or in your script
/^(?!['"])[\x00-\x7F]*$/
Edit:
,
IMO the easiest solution:
/^[\x00-\x21\x23-\x26\x28-\x7F]*$/
Source: https://habr.com/ru/post/1628940/More articles:Error after adding YahooSDK - iosHow to restart a controlled task that fails - elixirParsing a string with recursive parentheses - phpPHP regex parsing data between [] - jsonTransitional underscores for multiple lines of text - htmlHow to set a different version number in Android build types? - androidKnockoutJs components with RequireJs and TypeScript - javascriptSaving a fragment on the reverse side when changing orientation - androidCounting records with corresponding records that appear first on a given date - joinQt Property Browser Framework или аналогичный в python - pythonAll Articles