原帖由 __lxmxn__ 于 2008-3-13 16:48 发表
my $str='the first file is abc.jpg the second file is cba.jpg the third file is bac.jpg and';
if($str=~/\.jpg.*?(\w+\.jpg)/){
print 'filename is ',$1;
}
<lig@other-server:~/chinaunix>$ ./match
abc.jpg
<lig@other-server:~/chinaunix>$ ./match 1
cba.jpg
<lig@other-server:~/chinaunix>$ ./match 2
bac.jpg
<lig@other-server:~/chinaunix>$ ./match -1
bac.jpg
<lig@other-server:~/chinaunix>$ ./match -2
cba.jpg
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |