Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you extract a value from a string

Status
Not open for further replies.

csphard

Programmer
Apr 5, 2002
194
US
Hi I have a value that returns from a service. The value comes back as miles space mi. So it will look like
24.1 mi

I want to strip out  mi returning the number.

Is there a javascript function that would allow me to do that.

Any suggestions.

thanks

howard
 
If you have this string:

Code:
var theVal = '24.1 mi';

then this will strip the NBSP:

Code:
var theVal = '24.1 mi'.replace(' ', '');

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top