text search with regular expression – escape pipe character

I have data in big text file which is like

myimg1

I want remove from "_abc" to first pipe character. I am using _abc.+\| with regular expression but it is selecting till last pipe character, where i want to select only till first pipe character.

myimg2

How can i select only from _abc to first pipe character.

>Solution :

Here is my recommendation:

_abc\s*\|

This will select everything between "_abc" and the first pipe.

If you need the first pipe incl:

_abc\s*\|[^|]*\|

You can test it by your own here:
Regex101

Leave a Reply