2016-12-02 6 views
-2

私はファイルを持っていて、パターンの一致するまでの行の開始から置き換える必要がある単語に基づいて、行の中央に単語があります。regex perl replace

サンプルライン:ここ

the browser separates off the name/value pairs and other information which is sent in the header and puts it in

私たちは言葉otherを見つけると、単語事前にthe

おかげでotherまでラインの始点から交換する必要があります。

+0

たプログラミング言語で、あなたがこれを行うにしたいですか? – bharadhwaj

+6

私たちはかなり多くの人が答えられる必要があります。 See [ask]。少なくとも、サンプルの入力と出力、そしてこれまでに試したことと、どこに止まっているのか。 – Sobrique

答えて

1

あなたはこれを期待していることがあります

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 
+1

downvoteの理由を述べる必要がありますか? – ssr1012