Re: 想請教一下 perl 中的字串取代

看板Programming作者 (Kornelius)時間18年前 (2007/09/22 01:27), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串12/12 (看更多)
我的方法是 用 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

09/22 01:27, , 1F
這個方式沒看過 thx :)
09/22 01:27, 1F
※ 編輯: kornelius 來自: 61.223.100.79 (09/22 01:28)
文章代碼(AID): #16y_x_y9 (Programming)
討論串 (同標題文章)
文章代碼(AID): #16y_x_y9 (Programming)