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

Re: Pattern Matching - Remove Alpha

Thread Previous | Thread Next
Michael Fowler
January 18, 2002 16:29
Re: Pattern Matching - Remove Alpha
Message ID:
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:
> > >  "$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.

Michael "Fun with Language" Fowler
Programmer, System Administrator

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About