Community
    • Login

    Move Line Up

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 33 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.
    • Barry LortB
      Barry Lort
      last edited by

      Hello, my project manager wants me to move the “#DESCRIPTION” line above the “#SERVICE” line. Our master list contains several hundred entries. Can I highlight all “#DESCRIPTION” lines and move them above the “#SERVICE” line?

      Thank you.

      #SERVICE:4:8:1:6:0
      #DESCRIPTION   Angus
      #SERVICE:4:7:0:3:0:
      #DESCRIPTION   Ayrshire 
      #SERVICE:5:8:4:1:0
      #DESCRIPTION   Brown-Swiss
      #SERVICE:3:6:7:1:0
      #DESCRIPTION   Galloway
      #SERVICE:4:9:2:5:0
      #DESCRIPTION   Guernsey
      #SERVICE:6:4:7:8:0
      #DESCRIPTION   Hereford 
      #SERVICE:2:7:4:1:0
      #DESCRIPTION   Holstein
      #SERVICE:6:4:2:9:0
      #DESCRIPTION   Piedmontese 
      #SERVICE:3:6:3:1:0
      #DESCRIPTION   Scottish-Highland
      #SERVICE:4:4:9:3:0
      #DESCRIPTION   Shorthorn
      
      PeterJonesP 1 Reply Last reply Reply Quote 1
      • PeterJonesP
        PeterJones @Barry Lort
        last edited by PeterJones

        @Barry-Lort ,

        FIND = (^#SERVICE.*)(\R)(^#DESCRIPTION.*)(\R?)
        REPLACE = $3$2$1$2
        SEARCH MODE = Regular Expression

        This puts the #SERVICE line in memory slot 1, the newline in memory slot 2, the #DESCRIPTION in memory slot 3, and the second newline in slot 4. (But because files sometimes don’t end in a newline, I made it optional with the ?

        The replacement uses slot 3, then 2, then 1, then 2 again, to swap the order of 1 and 3, and to make sure there’s always a newline, whether it was the last line of the file or not.

        ----

        Useful References

        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find other regular expressions (regex) documentation
        Barry LortB 1 Reply Last reply Reply Quote 1
        • Barry LortB
          Barry Lort @PeterJones
          last edited by

          @PeterJones

          Yes that works very well. Thank you so much. So the $ is a “backreference” in replacement strings when using regular expressions in the Find and Replace dialog?

          Barry

          Barry LortB 1 Reply Last reply Reply Quote 0
          • Barry LortB
            Barry Lort @Barry Lort
            last edited by

            Ok I see the “Useful References” link under Regex Special Characters for Searches, that explains it pretty well.

            Thanks again.

            Barry

            1 Reply Last reply Reply Quote 1
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors