Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the rest of the line after a specific string

So I am trying to remove the rest of the line after specific string on a document but I am finding it hard.

The lines look similar to this

abc:abc|bca:111 222|ccc:01/01/17
abc:abc|bca:bca bca|ccc:02/02/17

I am trying to delete everything after abc:abc including | but I don't know how.

I tried it with this on notepad+ \|.bca* but when I click Replace all it selects whole document.

like image 682
rea Avatar asked Sep 06 '25 20:09

rea


1 Answers

  • Ctrl+H
  • Find what: \|.*$
  • Replace with: LEAVE EMPTY
  • check Wrap around
  • check Regular expression
  • DO NOT CHECK . matches newline
  • Replace all

Explanation:

\|  : pipe character
.*  : 0 or more any character but newline
$   : end of line 

Result for given example:

abc:abc
abc:abc
like image 198
Toto Avatar answered Sep 10 '25 06:09

Toto