[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

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
0
singh101
Asked:
singh101
  • 3
1 Solution
 
CEHJCommented:
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now