[英]RegEx between two strings
How would I get the "$0.00" in between this font tag? 如何获得该字体标签之间的“ $ 0.00”?
<font color="#99002B">
$0.00
</font>
This is the only one on the page I want to get. 这是我要获取的页面上唯一的一个。
I really don't understand regex, so maybe someone could help whilst they answer too! 我真的不了解正则表达式,所以也许有人在回答的同时也可以提供帮助!
Thanks 谢谢
EDIT: The $ sign isn't always there either. 编辑:$符号也不总是在那里。 It might be, for example;
例如,可能是。
EUR 0,00
£ 4.44
EUR 0,00
£ 4.44
You've asked for a regular expression here, but it's not the right tool for parsing HTML. 您已经在这里要求使用正则表达式,但这不是解析HTML的正确工具 。
$doc = new DOMDocument;
$doc->loadHTML($html); // Load your HTML data
$xpath = new DOMXPath($doc);
$node = $xpath->query("//font[@color='#99002B']")->item(0);
echo $node->nodeValue; //=> "$0.00"
/<font color="#99002B">\n?(.+[0-9]+\.[0-9]+)\n?<\/font>/
Working demo: http://refiddle.com/refiddles/53efdb3b75622d2c63940500 工作演示: http : //refiddle.com/refiddles/53efdb3b75622d2c63940500
If there are some more spaces around use: 如果周围还有其他空间:
/<font color="#99002B">\s*(.+[0-9]+\.[0-9]+)\s*<\/font>/
Maybe you have to replace all "\\n"
by ""
before it works - haven't tested. 也许您必须先将所有
"\\n"
替换为""
然后才能使用-未经测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.