Link to home
Start Free TrialLog in
Avatar of joedunn
joedunn

asked on

Replace Letters in String with Numbers

I need to have a simple JavaScript form on a page that a user can enter a MAC Adress and have it 'translated' to the numbers the user would push on their telephone keypad to enter the number.  Very similar to a 1-800 number when the telephone number spells out a word - 1-800-GET-BEER would be 1-800-438-2337.  In this case however, it is much simpler as there are far fewer letters.

If someone could give me the whole html page from <html> to </html> that would be awesome!

Here are the basic rules for this translation:

i.      0  9 = 0  9
ii.      A = 22
iii.      B = 222
iv.      C = 2222
v.      D = 33
vi.      E = 333
vii.      F = 3333

So if I typed into the form:  000b8200e395  I would get the number -->  0002228200333395

The 'B' was converted to '222' and the 'E' was converted to '333' and the string was put back together.


Thanks!!!
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Zvonko's answer is better. I was never really good at Regular expressions.
Thanks :)
Forced accept.

Computer101
EE Admin