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:
OCF|DINHEIRO|160.12
So I started doing a regular expression in notepad ++;
In which I can find exactly what I want to search.
The expression is this:
(^OCF|)(w*|)(d*.d*)
Now I need to know how to replace all so that the value I expect is generated:
OCF|DINHEIRO|160.12
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 inregex
has the function ofOU
-
d+
shortcut to search for numbers greedy. -
$
border that searches the end of a string.
Running
let texto = 'OCF|DINHEIRO|160.12|12';
let expressao = /|d+$/;
console.log(texto.replace(texto.match(expressao),''));
Regex101