嗨,這是現在工作,但我很困惑,爲什麼。正則表達式和逗號
我學習正則表達式,需要拉出來的數字串像
'Discount 7.5%' should get 7.5
'Discount 15%' should get 15
'Discount 10%' should get 10
'Discount 5%' should get 5
等
/\d,?.\d?/ //works
/\d,?.\d,?/ //doesn't works
/\d?.\d?/ //doesn't works
我認爲第二兩個中的一個會的工作可能有人解釋這一點。
** 1。**您應該在\,** 2之前使用\ \ + +來匹配多個數字** 3 **在任何正則表達式中不需要''' – Tushar
定義「不起作用」。 – RobG
[DOT正則表達式]的可能重複(http://stackoverflow.com/questions/3862479/regular-expression-for-dot) – Basilevs