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:<gpxtpx:hr>115</gpxtpx:hr> <gpxtpx:cad>90</gpxtpx:cad>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.
Terry
-
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: \1What 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
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