Community
    • Login

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

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

            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
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors