Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Stripping characters from begining and end of a string

Posted on 2011-03-10
3
Medium Priority
?
368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

647 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