macros - notepad++ replace a string in next (3 or 4 ) lines -


i have text file of 183419 lines, replace entire line of:

3 _type photo   

with:

3 _type document   

but if 3 or 4 lines after line begins with:

3 file d:\genie\grogan\doc\......   

for example:

3 file d:\genie\grogan\doc\mills\mills albert 1884 birth partial transcript.jpg   3 titl mills albert 1884 birth partial transcript   3 _scbk y   3 _type photo 

or:

3 file d:\genie\grogan\doc\mills\mills albert 1884 deathtranscript.jpg   3 titl mills albert 1884 deathtranscript   3 _scbk y   3 _prim y   3 _type photo 

but not situation:

3 file d:\genie\grogan\photos\grogan edward\grogan thelma simpson jim.jpg   3 _scbk y   3 _type photo 

this task required run monthly.

do regular expression search , replace, ensure dot matches newline not selected. setting find what ^(3 file d:\\genie\\grogan\\doc\\(.*\r\n){3,4})3 _type photo$ , replace with \13 _type document.

the (.*\r\n){3,4} part matches end of genie\\grogan\\doc line plus 2 or 3 more complete lines. (3 file ... )3 _type photo$ part matches 2 specified strings , enclosing brackets capture text except line replaced. \1 in replacement string inserts captured text, rest of string new text wanted.

tested notepad++ 6.3.2 on test lines.

depending on line endings, may need adjust \r\n part of find what string. examples not cover options, may need change {3,4} part {4,5} depending on exact meaning of "only if 3 or 4 lines after"


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -