Stripping characters from begining and end of a string

I want to remove numbers only from the begining of a string and the end of a string

1TestUser12324" -> "TestUser"
12Test3User12324" -> "Test3User"

How could this be done?

Many thanks
singh101Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
CEHJConnect With a Mentor Commented:
Try
s = s.replaceAll("^\\d+", "").replaceAll("\\d+$", "");

Open in new window

0
 
CEHJCommented:
More concise:

s = s.replaceAll("^\\d+|\\d+$", "");

Open in new window

0
 
CEHJCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.