admin管理员组文章数量:1326447
I have a regexp that matches all ascii characters:
/^[\x00-\x7F]*$/
Now I need to exclude from this range the following characters: '
, "
. How do I do that?
I have a regexp that matches all ascii characters:
/^[\x00-\x7F]*$/
Now I need to exclude from this range the following characters: '
, "
. How do I do that?
- You can refer to this link: stackoverflow./questions/1127739/… – Calyfs0 Commented Feb 16, 2016 at 8:18
3 Answers
Reset to default 5You can use negative lookahead for disallowed chars:
/^((?!['"])[\x00-\x7F])*$/
RegEx Demo
(?!['"])
is negative lookahead to disallow single/double quotes in your input.
You can exclude characters from a range by doing
/^(?![\.])[\x00-\x7F]*$/
prefixed it with (?![\.])
to exlude .
from the regex match.
or in your scenario
/^(?!['"])[\x00-\x7F]*$/
Edit:
wrap the regex in braces to match it multiple times
/^((?!['"])[\x00-\x7F])*$/
The IMO by far simplest solution:
/^[\x00-\x21\x23-\x26\x28-\x7F]*$/
本文标签: javascriptmatch ascii characters except few charactersStack Overflow
版权声明:本文标题:javascript - match ascii characters except few characters - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742214359a2434293.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论