Sagar Sagar -4 years ago 178
Javascript Question

How to extract float value from a string in Jquery

My string contain following value in it.

var Test = "3700 NO LAND VALUE (Lease Property) (0.10)"

Now how can i retrieve only 0.10 from above string.
output must be 0.10 not 3700

Answer Source

You can use this regex

var Test = "3700 NO LAND VALUE (Lease Property) (0.10)"
var regExp = /\(([0-9|.]+)\)/;  
var matches = regExp.exec(Test);
var result = matches[1];

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download