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!

string left and len

Status
Not open for further replies.

LeoLionHeart

Programmer
Apr 4, 2006
45
GB
I have a string such as 013548 - Jo Bloggs. How do I just return the number part.

For example, I want to loop from 1 to the length of the string. If the value = ' - ' Then exit loop. Store the position of the '-' and calculate left(string, strored position -2).

Any ideas?
 
Solved

Code:
var name=name.substring(0,name.indexOf('-')-1);

where name is my string
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top