Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Java String character replace A=1 through to Z=26

Avatar of kineticexpert
kineticexpertFlag for Australia asked on
2 Comments1 Solution883 ViewsLast Modified:
I have an input string like so: "AB123" (without quotes).

I need to take the first two characters (A and B) and then individually find out integer values for them based on the following logic:

For the first character: A = 1, B = 2, C = 3, right through to Z = 26.

For the second character: A = 01, B = 02, C = 03, right through to Z = 26.. the only difference from the first character, is that  this number is padded.

I need error checking (in the event of the first 2 characters not being letter), and then replacing the new values to the rest of the string.

few examples...
ie. Input: AB123    Output: 101123
ie. Input: ZZ567    Output: 2626567


Avatar of Mick Barry
Mick BarryFlag of Australia imageJava Developer
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers