I'm facing a herculean task in multiline find and replace (explained in separate parts).
The solution I seek involves using regex in Notepad++ with either the built in Find & Replace or with the multiline search and replace dialog made available by the NPPtoolbucket plugin.
This is an example extract of the input file:
ALPHA('Hello John')
IGNORE111
IGNORE222
BETA('Hi Mary')
I need to replace Hi Mary (fourth line) with Hello John (content fetched from first line). i.e, the actual content in the fourth line between BETA(' and ') should be replaced by the content fetched between ALPHA(' and ') from first line.
The desired outcome should be:
ALPHA('Hello John')
IGNORE111
IGNORE222
BETA('Hello John')
The issue I'm facing is I have 47 IFC files with (12000+ lines each). These files have an assembly name in the first line (unique to each IFC file) and it needs to be used to replace content somewhere in lines 48, 87 and many more lines in all of the 47 IFC files. It all follows a particular pattern. Can you suggest any trick to achieve this using regex?
Say like - find using (ALPHA\(')(.*)(')(NEW_SYNTAX_I_SEEKING)(BETA\(')(.*)(')
and replace with \1\2\3\4\5\2\7
where
(ALPHA\(')
will become back ref \1
(.*)
will become back ref \2
, it will split as -> Hello John
(')
will become back ref \3
(NEW_SYNTAX_I'M_SEEKING) will become back ref \4
; this will be the new regex syntax I'm looking for, which will fetch content spread across multiple lines and the one I dont want any change
(BETA\(')
will become back ref \5
(.*)
will become back ref \6
, it will split as -> Hi Mary, so we can use back ref \
2 to replace back ref \6
.
(')
will become back ref \7
Hope I got my question & intention articulated properly. I'll highly appreciate any help given.
Cheers, JJ