Re: Stripping numbers from a string
- From: "it_says_BALLS_on_your forehead" <simon.chao@xxxxxxx>
- Date: 30 Jan 2006 15:26:46 -0800
Matt Garrish wrote:
> "it_says_BALLS_on_your forehead" <simon.chao@xxxxxxx> wrote in message
> news:1138660045.508919.71590@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> >
> > Ninja67 wrote:
> >> This should be an easy one for you seasoned perl developers.
> >>
> >> I've got a string that may or may not begin with one or more numbers.
> >> For example, it might be "Smith, John" or it might be "83Smith, John".
> >>
> >> I only want the text portion of the string. How do I make sure that
> >> regardless of which of the above is passed to me, I only get "Smith,
> >> John"?
> >
> >
> > my $string = '83Smith, John';
> > $string =~ s/\d//g;
> >
>
> Or more safely:
>
> $string =~ s/^\d+//;
>
> Who knows when you'll run into "83Smith 4th, John"...
excellent point. when i read that the OP only wanted the text portion
of the string, i (possibly erroneously) designed a simple regex to
delete all digits from the string, regardless of position. i should
have looked more closely at the OP's first paragraph.
.
- Follow-Ups:
- Re: Stripping numbers from a string
- From: it_says_BALLS_on_your forehead
- Re: Stripping numbers from a string
- References:
- Stripping numbers from a string
- From: Ninja67
- Re: Stripping numbers from a string
- From: it_says_BALLS_on_your forehead
- Re: Stripping numbers from a string
- From: Matt Garrish
- Stripping numbers from a string
- Prev by Date: Re: Stripping numbers from a string
- Next by Date: Re: Stripping numbers from a string
- Previous by thread: Re: Stripping numbers from a string
- Next by thread: Re: Stripping numbers from a string
- Index(es):
Relevant Pages
|
|