作者Xphenomenon (啦 )
看板perl
标题Re: [问题] 字串取代 Regular Expression
时间Wed Oct 3 18:26:48 2007
※ 引述《Xphenomenon (啦 )》之铭言:
: $line =~ /(alert|confirm) *\( *([\'\"][^;]*)\)/
: 请问一下 如果我只想取代 $1 的话, 是否可以做到呢?? 还是只能全部取代呢?
: 谢谢各位大大~~
不好意思 说的不是很清楚
假设
$line = "hello, world";
$line =~ s/(hello)(, world)//;
如果我只是想取代 ", world" 成为 ", Perl"
而不是取代整个 "hello, world" 字串是否可以做到呢??
我的前提是如果我搜寻整个 "hello, world" 而不是单独的 "world" 去取代,
例如 $line =~ s/, world/, Perl/;
不知道可不可以做到呢?? 谢谢各位大大的回答~ :)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.104.56.127