How to extract decimal number from string using JavaScript

javascript, jsp, regex, struts-1

Solution

You can use regex like this,

Live Demo

var amount = "$265.12+";
var doublenumber = Number(amount.replace(/[^0-9\.]+/g,""));

Problem

I want to extract decimal number `265.12` or `0.0` from alphanumeric string (say amount) having value `$265.12+` or `$265.12-` or `$0.0+` or `$0.0-` and use it apply struts logic tag in JSP. Not sure how to extract number maybe with help of JavaScript.

Original source