Re: Pattern Matching - Remove Alpha

2002-01-20 Thread Roger C Haslock
t: Saturday, January 19, 2002 12:28 AM Subject: Re: Pattern Matching - Remove Alpha > 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-z

Re: Pattern Matching - Remove Alpha

2002-01-18 Thread Michael Fowler
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 "idiomati

Re: Pattern Matching - Remove Alpha

2002-01-16 Thread John W. Krahn
Hewlett Pickens wrote: > > I am unable to use "split" with pattern matching to remove alpha characters > from a string and will appreciate a pointer on what I'm doing wrong. (Have > looked in "Learning Perl" and "Programming Perl" but can't spot my error.) > > The detail: > > "$stat" is a stri

Re: Pattern Matching - Remove Alpha

2002-01-16 Thread Michael Fowler
On Wed, Jan 16, 2002 at 05:38:56PM -0600, Hewlett Pickens wrote: > The detail: > > "$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. > > The first attempt: > >my @nums = split(/a-zA-Z/,$stat); # removes

RE: Pattern Matching - Remove Alpha

2002-01-16 Thread Wagner-David
Could do something like: @MyNbrs = map{ /(\d+)/g } $MyInp; Small script: my @MyNbrs = (); while ( 1 ) { printf "Please enter string of data:\n"; chomp(my $MyInp = ); last if ( $MyInp =~ /^ex$/i ); @MyNbrs = map{ /(\d+)/g } $MyInp; my $MyCnt = 1; foreach ( @MyNbrs )