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
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
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
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
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 )