正则表达式与欧元符号 [英] Regex with EURO symbol
本文介绍了正则表达式与欧元符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Regex从HTML页面获取一些价格。我有适用于£和$的工作字符串,但是一旦我将其更改为欧元并将货币符号放在正则表达式字符串的末尾,它似乎就无法工作。
I'm using Regex to grab a few prices from a HTML page. I have working strings for both £ and $ but as soon as I change it for Euros and place the currency symbol at the end of the regex string it doesn't seem to work.
这是我的代码: preg_match('/([[0-9] + [\。] * [0-9] *)\€/',$ totalprice,$ value);
但是$ value返回一个空数组。
Yet $value returns an empty array.
谢谢!
推荐答案
这似乎与编码有关。
$totalprice = "595,95€";
preg_match('/((?:[0-9]*[.,])?[0-9]+)\p{Sc}/u', $totalprice, $value);
print_r($value);
这篇关于正则表达式与欧元符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文