arcanine
arcanine

Reputation: 1953

get specific string after first occurance of string regex sublime text 2 find & replace

include_once($pathToRoot.'header.php');  
echo('</div>');

assume you have variations on the above code across hundreds of files, how do you match against the first occurrence of

</div>

after

header.php' 

?

Upvotes: 0

Views: 1450

Answers (2)

Teddy Bo
Teddy Bo

Reputation: 679

In the find field: (?s)(header\.php'.+?)</div>

In the replace (if you what to replace </div> with </test>): $1</test>

Upvotes: 2

rekire
rekire

Reputation: 47945

I don't know that sublimetext2 but the regular expression would look like this:

/include_once\($pathToRoot.'header.php'\);(.*?)(<\/div>)/s

The first group would be the string between the include and the closing div and the second group would be the closing div itself.

Upvotes: 0

Related Questions