How to delete a certain group from the regular expression

Posted on

Question :

I have a tax file that comes with the following information in the line:

Ex:. OCF|DINHEIRO|160.12|12

To fix it I have to delete a part, and the right one would be:


So I started doing a regular expression in notepad ++;
In which I can find exactly what I want to search.
The expression is this:


Now I need to know how to replace all so that the value I expect is generated:



Answer :

The idea is to look for the pattern you want to remove. So I understand you want to remove |12 at the end of the text, ie the default you are looking for is |nĂºmero

My expression is based on the following:

  • | looks for a slash, escape is required because the slash in regex has the function of OU
  • d+ shortcut to search for numbers greedy.
  • $ border that searches the end of a string.


let texto = 'OCF|DINHEIRO|160.12|12';
let expressao = /|d+$/;



If the expression is used in the Notepad ++ editor, do as Marconi said.

Access the shortcut CTRL+H and in the Find what field put the expression |d+$ and click Replace All .



Leave a Reply

Your email address will not be published. Required fields are marked *