View Single Post
Old 28-01-2008, 06:55   #1 (permalink)
paulanthony
mingin dawg baitch
 
paulanthony's Avatar
 
Join Date: Apr 2004
Location: Belfast
Posts: 1,035
Send a message via MSN to paulanthony
Javascript Letters to Numeric?

Guys if I have a string such as

2WAY002
or
2WAY001

What is the best way to get rid of the characters in the middle of the string and convert them to numbers in Javascript. My initial thoughts was a function to get the position in the alphabet i.e. A=1 and change to a number.

Is there any better way? would parseInt do anything for me? or a regex?

My reason for doing this is that these codes are going into a database from a CSV file...and need to be numeric. I wish to run a javascript parser over the file first and modify the data.
__________________
  Reply With Quote