develooper Front page | perl.beginners | Postings from January 2002

Re: Pattern Matching - Remove Alpha

Thread Previous | Thread Next
From:
Michael Fowler
Date:
January 18, 2002 16:29
Subject:
Re: Pattern Matching - Remove Alpha
Message ID:
20020119002844.GB6273@shoebox.net
On Wed, Jan 16, 2002 at 09:51:45PM -0500, Tanton Gibbs wrote:
> Michael brings up a good point...for this problem, you would probably be
> better served by tr
> 
> $stat =~ tr/a-zA-Z//d;
> 
> will delete any alpha character.
> 
> Although split will do the job, I think tr would be a more "idiomatic"
> choice, probably more efficient too.

That might work, except one of his requirements is that the numeric data be
placed into an array.

tr/// is more efficient; I can't really guage its level of idiomicity
compared to split.


> > On Wed, Jan 16, 2002 at 05:38:56PM -0600, Hewlett Pickens wrote:
[snip]
> > >  "$stat" is a string that has alpha and numeric data in it.
> > >  I want to remove all of the alpha and put the numeric data into an array.
[snip]


Michael "Fun with Language" Fowler
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About