Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Insert a new line text after a line containing specific text

    Help wanted · · · – – – · · ·
    2
    3
    216
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Charles Carmichael
      Charles Carmichael last edited by

      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

      Alan Kilborn Charles Carmichael 2 Replies Last reply Reply Quote 0
      • Alan Kilborn
        Alan Kilborn @Charles Carmichael last edited by

        Many ways to achieve it; IMO the best way is:

        Find: </MINQTY>(\R)
        Replace: $0<CONDITION>N</CONDITION>${1}
        Search mode: Regular expression

        But 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 …

        1 Reply Last reply Reply Quote 2
        • Charles Carmichael
          Charles Carmichael @Charles Carmichael last edited by

          @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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright © 2014 NodeBB Forums | Contributors