Community
    • Login

    Quick delete/replace of lines in GPX/TCX file ?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 1.4k 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.
    • Алексей ТрофимовА
      Алексей Трофимов
      last edited by

      Hi all.
      I need delete or (if it’s not possible) replace with zero data many lines like this:

        <gpxtpx:hr>115</gpxtpx:hr>
        <gpxtpx:cad>90</gpxtpx:cad>
      

      Of course digits are not the same in every line…

      1 Reply Last reply Reply Quote 0
      • Алексей ТрофимовА
        Алексей Трофимов
        last edited by

        OK, as I see

        Replace gpxtpx:hr.*</gpxtpx:hr> is working…

        But how can I quickly delete an empty lines ?

        1 Reply Last reply Reply Quote 0
        • Terry RT
          Terry R
          last edited by

          Find \R\R and replace with an empty string should do it, unless your “text” file has a different character set.

          You’d need to determine the exact character which denotes a carriage return/line feed for your text file. Whatever the character is, an empty line should mean 2 of these characters together. Search for those and replace with an empty string.

          Terry

          1 Reply Last reply Reply Quote 0
          • Terry RT
            Terry R
            last edited by

            Sorry, I need to revise slightly my previous answer. If you follow that solution you will finish with 2 lines combined. I’ve actually considered a slightly better answer.

            Find: (\R)\R+
            Replace: \1

            What this does is find the first CR/LF (you may need to replace \R with the correct CR/LF character your file has). Then there has to be 1 or more additional CR/LF characters. We only keep the first CR/LF character, removing all others. This will cater for situation of multiple empty lines together, as \R+ greedily consumes as many CR/LF characters as possible.

            I have to ask the question though, is the line truly empty or does it have 1 or more spaces in it? Spaces will require a different expression. If spaces then:
            Find: (\R)\h*\R+
            Replace: \1
            The caveat here is that \h refers to both a horizontal space, a tab and a line feed. Depending on the character set used a \h might also refer to part of your CR/LF. If so then replacing \h with \s might fix it.

            Terry

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