9

For example I have:

Apple:123456789:pear
watermelon:57952161354:kfc

How do I delete the text that's between the ":" to get this:

Apple:apple
watermelon:kfc
21

How do I replace all text between 2 :s with a single :?

  • Menu "Search" > "Replace" (or Ctrl + H)

  • Set "Find what" to :.*?:

  • Set "Replace with" to :

  • Enable "Regular expression"

  • Click "Replace All"

Image

Before:

Apple:123456789:pear 
watermelon:57952161354:kfc

After:

Apple:pear 
watermelon:kfc

Further reading

  • I would say that :[^:]++: would be much more efficient - but that only really matters if the text file is large. You could also try replacing :[^:]++(?=:) with the empty string - but I'm not sure if notepad supports lookaround. – Boris the Spider Nov 22 '15 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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