Notepad++ How to delete everything before the first Colon

Example Text:

test3:orange;mango
test324:cherry;peach
test35:apple;pear

I want to get delete the 'test' part on every line.

I know there is an expression for deleting everything before the first colon.

2 Answers

  • Ctrl+H
  • Find what: ^[^:]+ or ^[^:]+: if you want to remove also the colon
  • Replace with: LEAVE EMPTY
  • check Wrap around
  • check Regular expression
  • Replace all

Explanation:

^ : beginning of line [^:]+ : 1 or more any character that is not a colon : : a colon (only if you want to remove it)

Result for given example:

:orange;mango
:cherry;peach
:apple;pear

OR

orange;mango
cherry;peach
apple;pear

Open the "Find and Replace Dialogue" (Ctrl + H assuming Windows) and enable the Regualar Expression search mode. The following regular expression in the search box will highlight "test" followed by any text up to and including the colon:

^(test).*:

You can leave the "Replace With" box empty and click "Replace All" to simply delete all instances in a file, or enter a colon in the "Replace With" box to keep the colon.

See the image below for reference

enter image description here

You can learn more about Regular Expressions from Microsoft's Regular Expression Language - Quick Reference

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like