正则表达式抓取表单标签内容不起作用
我正在尝试使用 preg_match_all 获取表单标签内的内容/标签,这是正则表达式
/<form\b[^>]*>(.*?)<\/form>/i
但我想知道,为什么它不起作用!有什么想法吗?
I am trying to grab contents/tags inside form tag using preg_match_all, here is the regular expression
/<form\b[^>]*>(.*?)<\/form>/i
But i wonder, why it doesn't work! Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
默认情况下,
.
(DOT) 不匹配换行符。如果您使用s
修饰符启用 DOT-ALL,它确实会匹配这些字符:意识到您将无法匹配类似的内容:
仅列出其中一种可能性。
By default, the
.
(DOT) does not match line breaks. If you enable DOT-ALL with thes
modifier, it does match those chars:Realize that you won't be able to match something like:
to name just one of the possibilities.
不要使用正则表达式来解析 HTML。使用 HTML 解析器。
Don't use regular expressions to parse HTML. Use an HTML parser.