HTML5 输入模式搜索报价
我需要针对此正则表达式测试输入字段 ():
[^'"]+
这显然不是一件容易的任务,因为我无法在内部使用 "
使用 quot 实体似乎不起作用,因为它是由正则表达式引擎逐字解释的
。
I need to test an input field (<input type="text" />
) against this regex:
[^'"]+
This obviously is no easy task as I cannot use "
inside the attribute. Using the quot entity does not seem to work as it gets interpreted literally by the regex engine.
How can I accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
HTML5 @pattern 属性正则表达式基于 JavaScript 正则表达式,因此您可以像在 JavaScript 中一样为该字符使用十六进制表示法或unicode 表示法:
以便您可以轻松使用
田田!不涉及 JavaScript 库! ;)
The HTML5 @pattern attribute regex is based on JavaScript regex, so you can use hexadecimal notation or unicode notation for that char as you would in JavaScript:
So that you can easily use
TADA! No JavaScript libraries involved! ;)
您可以使用十六进制表示法代替
'
或"
。You can use Hexadecimal notation instead of
'
or"
.