Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > String Manipulation

Reply
Thread Tools

String Manipulation

 
 
TheVooDooChild
Guest
Posts: n/a
 
      03-25-2005
I have an alpha-numeric string. If the 1st position is non-numeric, I
need to remove it. For some reason this is causing me difficulty. Can
someone show me a way to do this? Example: "R123456789" I want
"123456789"

Thanks.

 
Reply With Quote
 
 
 
 
Fahd Shariff
Guest
Posts: n/a
 
      03-25-2005
String s = "R123456789" ;

//get first char
char c = s.charAt(0) ;

//is it non-numeric?
if(!Character.isDigit(c)){
//remove it
s = s.substring(1,s.length());
}

--
Fahd Shariff
http://www.fahdshariff.cjb.net
"Let the code do the talking... "

 
Reply With Quote
 
 
 
 
TheVooDooChild
Guest
Posts: n/a
 
      03-25-2005
Thank you!

 
Reply With Quote
 
Lisa
Guest
Posts: n/a
 
      03-25-2005

"Fahd Shariff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> String s = "R123456789" ;
>
> //get first char
> char c = s.charAt(0) ;
>
> //is it non-numeric?
> if(!Character.isDigit(c)){
> //remove it
> s = s.substring(1,s.length());
> }
>


you can use "s = s.substring(1);"
instead of specifying the length explicitly

> --
> Fahd Shariff
> http://www.fahdshariff.cjb.net
> "Let the code do the talking... "
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
String manipulation Chris ASP .Net 1 05-24-2004 02:19 PM
Advanced String Manipulation (C#) Aaron ASP .Net 2 01-02-2004 06:50 PM
String Manipulation Aaron ASP .Net 3 12-31-2003 03:39 PM
Perl string manipulation jared in ecs Perl 2 10-22-2003 05:36 PM
String Array Manipulation Problem Garfield ASP .Net 5 08-27-2003 10:07 PM



Advertisments