Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一种不允许在我的文本框“&”“<”和“>”中使用以下字符的方法。我知道正则表达式的语法并指定允许的字符:“^[A-Za-z0-9]+$”但我正在寻找指定文本字段中不允许的多个字符的语法。
谢谢你。
您可以通过将您不想要的字符放入[^...](注意^)中来创建一个“负面”字符类,如下所示:
[^...]
^
"^[^&<>]+$"