Home  >  Article  >  Backend Development  >  javascript - How to propose a price rule

javascript - How to propose a price rule

WBOY
WBOYOriginal
2016-08-04 09:21:03963browse

javascript - How to propose a price rule

最终匹配到2499.00,正则该怎么样写;

回复内容:

javascript - How to propose a price rule

最终匹配到2499.00,正则该怎么样写;

直接这样可以吗 substr("¥2499.00",3);

<code>("¥2,499,999.00").replace("¥","").replace(/,/g,"");

("¥499,999.00").replace(/[^\d\.]/g,"");
</code>

<code>"¥2,499.00".match(/¥([\d,]*?\.00)/)[1]
//2499.00
"¥2,99.00".match(/¥([\d,]*?\.00)/)[1]
//299
</code>

<code>var str='¥2,499.00';
str.replace(/[¥,]/g,''); // => 2499.00</code>

<code>var str = '$2,499.00';
str.match(/[\d.]/g).join('');</code>

如果字符串里面还有其他的字符,这样就可以了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn