Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In NotePad++, I want to remove everything after the third : character in a line.

So, the character would look like:

text:moretext:evenmoretext

How would I get rid of the evenmoretext?

share|improve this question
    
use regex to search and replace –  Shekhar Oct 7 '13 at 19:16
    
The text isn't the same every line. –  Layne Oct 7 '13 at 19:19
1  
check this post: superuser.com/questions/339601/… –  Shekhar Oct 7 '13 at 19:21
1  
1  
Remove everything after the second ":"? –  Axel Kemper Oct 7 '13 at 19:35

1 Answer 1

You can easily do so using Regexp search and replace

The regex to use is (put this into the Find what field on the Replace tab in the search window)

^([^:]*):([^:]*):.*$

And into Replace with enter

\1:\2

(if you need the ending : too, add it to the end of the Replace with string)

TL;DR

What does this all do?

This matches the beginning of the line:

^

This tells it to match a group, that consists of "everything that is not a : character"

([^:]*)

The literal : is matched by itself

And in the end, this matches "everything until the end of the line"

.*$

(the $ matches the "end of the line")

And the replacement means "put in the first group matched, followed by a :, and then the secound group matched".

share|improve this answer
    
I'm sure I will need this one day, hopefully I then remember this fav :) –  nixda Oct 7 '13 at 20:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.