Community
    • Login

    Insert a new line text after a line containing specific text

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 1.6k Views
    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 CarmichaelC
      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 KilbornA Charles CarmichaelC 2 Replies Last reply Reply Quote 0
      • Alan KilbornA
        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 CarmichaelC
          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
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors