preg_match_all 代表<选项>选项>;获取所有匹配的值
这是字符串。
$string = <option class="abcd" value="1.5">Some Text with White Spaces</option>
我想使用 preg_match_all 或类似的东西获取所有匹配变量(1.5
& Some Text with White Spaces
)。我很久以前就这样做过,但现在不记得了。希望你能帮忙...
Here is the string.
$string = <option class="abcd" value="1.5">Some Text with White Spaces</option>
I want to get all matching variables (1.5
& Some Text with White Spaces
) using preg_match_all or something similar. I was doing this a long ago but I don't remember it now. Hope you can help...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法回答 html & Stack Overflow 上的正则表达式问题,但未提及请使用解析器 >。
但是,如果您真的热衷于正则表达式,您可以看到下面的内容。
如果您的字符串看起来像这样,那么您可以使用...
$matches[1]
将具有value
属性和$matches[2]
将有文本节点。I couldn't answer a html & regex question on Stack Overflow without mentioning please use a parser.
However, if you were really keen on a regex, you could see below.
If your strings look like that, then you could use...
$matches[1]
will have thevalue
attribute and$matches[2]
will have the text node.