我有一个文件,并且该单词出现在该行的中间,基于从行的开头到模式匹配需要替换的单词。
示例行:
the browser separates off the name/value pairs and other information which is sent in the header and puts it in
在这里,我们需要找到单词other
并从行的开头替换为other
1>}的单词the
提前致谢。
答案 0 :(得分:0)
你可能期待这个:
use strict;
use warnings;
while(<DATA>) { $_=~s/^((?:(?!other).)*)other//i; print $_; }
__DATA__
the browser separates off the name/value pairs and other information which is sent in the header and puts it in
输出:
information which is sent in the header and puts it in