Solved

Stripping characters from begining and end of a string

Posted on 2011-03-10
3
360 Views
Last Modified: 2013-11-24
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
Comment
Question by:singh101
  • 3
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 35094185
Try
s = s.replaceAll("^\\d+", "").replaceAll("\\d+$", "");

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35094211
More concise:

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

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35095028
:)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now