Example Text:
test3:orange;mango
test324:cherry;peach
test35:apple;pearI 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;pearOR
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
You can learn more about Regular Expressions from Microsoft's Regular Expression Language - Quick Reference
1