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

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


    Of course digits are not the same in every line…

  • OK, as I see

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

    But how can I quickly delete an empty lines ?

  • 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.


  • 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.


Log in to reply