给你来个实例,一个正侧搞定。
  
  #!/usr/bin/perl -w
my $x="1234sdfdsf567890sdfz";
$x =~ s/\D//g;
print "$x\n";
  
  
  ------------------ 原始邮件 ------------------
  发件人: "Anthony WU"<[email protected]>;
 发送时间: 2010年12月28日(星期二) 晚上9:19
 收件人: "perlchina"<[email protected]>; 
 
 主题: Re: [PerlChina] 从字符串里面提取所有的数字

  
tr/0-9//cd

-------- Original Message  --------
Subject: Re: [PerlChina] 从字符串里面提取所有的数字
From: ZHANG Jiaqiang A <[email protected]>
To: [email protected]
Date: 28/12/2010 20:54
  我说个需求的例子吧
  a01b03c07.gz 提取后为010307
  
 x1.2_y3.0.zip 提取后为1230

   
 From: [email protected] [mailto:[email protected]] On Behalf 
Of smallfish
Sent: 2010年12月28日 20:51
To: [email protected]
Subject: Re: [PerlChina] 从字符串里面提取所有的数字


\d+
--   blog: http://chenxiaoyu.org





 2010/12/28 ZHANG Jiaqiang A <[email protected]>
   大家好,
  
 我想用Perl从字符串(实际是个文件 名)里面把所有的数字提取出来,是否可以用正则表达式实现,或是各位有其他思路?
  
 Jiaqiang

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。


-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

 

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

回复