regex - Javascript reg ex combination -
var cost_price = "15..00" / * Cost value should be such that there should be numbers and one Do not have more points than * / if (/ ^ ([0-9]). ([.]) /. Exam (cost_price) {documet.write ("true cost value"); } Now let me get the Hello message despite two points in cost_price if I should change in the condition?
P.S. I have 2 reg pre-combined one to see if the dot happens only once, checks for the accuracy of points and other investigations.
why not
/ ^ [0-9] + (\ [0- 9] +)? $ / And so make the final part completely optional? (? specifies " 0 to 1 times ") "
If you want to allow .15 , you first have to [0-9] + < / Code> (1 coincides with an infinite time) from [0-9] * (corresponds to 0 for eternity).
Comments
Post a Comment