从字符串获取价格值 [英] Get price value from a string
本文介绍了从字符串获取价格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串,其中价格值($ 544.50)可以在字符串中的任何位置。
例如:HP G60-630US笔记本:笔记本电脑| RadioShack.com-> $ 259.97(radioshack.com)
I have a string, where price value($544.50) can be anywhere in the string. eg: HP G60-630US Notebook: Laptops | RadioShack.com --> $259.97 (radioshack.com)
我需要获取值:259.97(字符串之外)
I need to get the value: 259.97 out of the string
为此,我尝试使用一些随机正则表达式。
但是没有运气!
For this i tried using some random regex's. But no luck!
有人可以帮助我,给出一个合适的正则表达式字符串来从字符串中检索该价格值。
Can someone help me, giving a proper regex string for retrieving this price value from a string.
谢谢。
推荐答案
此正则表达式可以使用多种货币:$£€
This regex will work with multiple currencies: $ £ €
[\$\£\€](\d+(?:\.\d{1,2})?)
这篇关于从字符串获取价格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文