How do I delete text between 2 characters?

9

5

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

hustler225

Posted 2015-11-22T14:56:28.993

Reputation: 99

Answers

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

DavidPostill

Posted 2015-11-22T14:56:28.993

Reputation: 118 938

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 – 2015-11-22T19:33:41.853