Insert a new line text after a line containing specific text
-
Hi,
I’m a complete novice to Notepad++ and I was wondering whether someone could provide me with clear easy instructions on how to insert a new line (with text) in multiple locations of an XML file.
For example I want to add a line of text containing"<CONDITION>N</CONDITION>" to the following block after the line that contains </MINQUANTITY>
So it would be:
<ITEM>
<ITEMTYPE>P</ITEMTYPE>
<ITEMID>3666</ITEMID>
<COLOR>1</COLOR>
<MINQTY>2</MINQTY>
</ITEM>to
<ITEM>
<ITEMTYPE>P</ITEMTYPE>
<ITEMID>3666</ITEMID>
<COLOR>1</COLOR>
<MINQTY>2</MINQTY>
<CONDITION>N</CONDITION>
</ITEM>Any help would be greatly appreciated.
Regards,
Charles -
Many ways to achieve it; IMO the best way is:
Find:
</MINQTY>(\R)
Replace:$0<CONDITION>N</CONDITION>${1}
Search mode: Regular expressionBut perhaps that won’t be exactly right because you lost leading whitespace from your real data when you posted? Oh, well…
Learn more about proper posting of questions like yours HERE.Learn more about regular expressions HERE.
clear easy instructions
Well, hopefully …
-
@Charles-Carmichael Thanks very much for this and also the guidance on how to post real data, shows you how much of a novice I am. Thanks again