作者kornelius (Kornelius)
看板Programming
标题Re: 想请教一下 perl 中的字串取代
时间Sat Sep 22 01:27:26 2007
我的方法是
用 cpan 模组 String::Interpolate 来解决 replace string 的 Interpolate
my $replace = safe String::Interpolate 'c$1d';
my $pattern = qr/^a\/(.*)/;
$_ = 'a/bcde/f';
s/$pattern/$replace/eg; # /e supresses optimisation
print;
即可
----
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.223.100.79
1F:推 LiloHuang:这个方式没看过 thx :) 61.230.172.181 09/22 01:27
※ 编辑: kornelius 来自: 61.223.100.79 (09/22 01:28)