方法一:- #!/usr/bin/perl
- use strict;
- use warnings;
- $"="";
- my $_='aA1一bB2二cC3三dD4四eE5五fF6六gG7七hH8八iI9九';
- my @lower=/[a-z]/g;
- my @upper=/[A-Z]/g;
- my @num=/[0-9]/g;
- my @hz=/[^a-zA-Z0-9]/g;
- print "@lower\n@upper\n@num\n@hz\n";
复制代码 方法二:- #!/usr/bin/perl
- use strict;
- use warnings;
-
- my $string='aA1一bB2二cC3三dD4四eE5五fF6六gG7七hH8八iI9九';
- my $lower=$string=~tr/a-z/ /cr;
- print "$lower\n";
- my $upper=$string=~tr/A-Z/ /cr;
- print "$upper\n";
- my $digit=$string=~tr/0-9/ /cr;
- print "$digit\n";
- my $hz=$string=~tr/a-zA-Z0-9//d;
- print "$string\n";
复制代码
|