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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login