[英]get price from string
I am trying to get a price and the plus or minus from a string using jquery. 我正在尝试使用jquery从字符串中获取价格和正负。
I'm pretty sure regex is the way to go, but I just can't seen to get it right. 我很确定正则表达式是行之有效的方法,但是我只是看不见正确的方法。
input: 输入:
Bla bla bla bla (- € 0.25) Bla bla bla bla(-€0.25)
should output: 应该输出:
direction = - 方向=-
amount = 0.25 数量= 0.25
What regexes should I use? 我应该使用什么正则表达式?
"[^€]*€[ ]*\([.[:digit:]]*\).*" -> "\1"
This is POSIX. 这是POSIX。 You can use it so: 您可以这样使用:
sed "s|[^€]*.[ ]*\([.[:digit:]]*\).*|\1|"
试试这样的事情:
/^(.+) \((\- ){0,1}€ ([0-9\.]+)\)$/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.