my $data = do { local $/ ; <DATA> } ;
my @digits = $data =~ /(\d+)/g ;
print Dumper \...@digits ;
__DATA__
abdfdafsdf1234sfdafdtegdd2345saste+-fsdfas578dsadfag
sdfsd12322sdfs“ da”gfgerfg643fgfdsa
2009/12/15 Tiger Peng <[email protected]>
> $ echo "abdfdafsdf1234sfdafdtegdd2345saste+-fsdfas578dsadfag
> sdfsd12322sdfs" da"gfgerfg643fgfdsa" |
> perl -ne 'print $1." " while /(\d+)/g'
> 1234 2345 578 12322 643
>
> 2009/12/14 wd <[email protected]>:
> > 为什么不能通过去除非数字的字符后剩下的作为值打印出来?
> > 直接把这些字符替换成空格?。。
> >
> > 2009/12/14 zhihua zheng <[email protected]>
> >>
> >> 如题:
> >>
> >> 问题: 我有大量类似的字符串(如下),需要把里面的数字全都获取出来, 首先我们不知道每一行里面有多少个数字串,可能没有,可能有,
> 要的就是有的那些,
> >> (不能通过去除非数字的字符后剩下的作为值打印出来)
> >>
> >> abdfdafsdf1234sfdafdtegdd2345saste+-fsdfas578dsadfag
> >> sdfsd12322sdfs“ da”gfgerfg643fgfdsa
> >> ....
> >>
> >>
> >> 我希望得到的结果是 :
> >>
> >> 1234 2345 578 12322 643
> >>
> >>
> >> 开动你的脑筋! 非常感谢了!
> >>
> >>
> >>
> >> --
> >>
> >> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> >> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> >> 要取消订阅此网上论坛,请发送电子邮件至
> >> [email protected]<perlchina%[email protected]>
> 。
> >> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
> >
> > --
> >
> > 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> > 要取消订阅此网上论坛,请发送电子邮件至
> > [email protected]<perlchina%[email protected]>
> 。
> > 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
> >
>
> --
>
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> 要取消订阅此网上论坛,请发送电子邮件至
> [email protected]<perlchina%[email protected]>
> 。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>
>
>
--
Yours Sincerely
Zeng Hong
--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。