Return first Number of each row?


I have this text and I want to replace each line with the first number that occurs in the line.


Affiliate,"0,00 €","1,13","0,00 €","0,00 €","0,00 %"
Bing - brand,"45,11 €","0,31","145,98 €","0,00 €","0,00 %"
Bing - nonbrand,"39,90 €","0,00","0,00 €","0,00 €","0,00 %"

Would become:


Can you help me on that?

My so far regex is:
with output $2

But that looks terrible and also doesn’t give me the wanted result.

Thanks in advance

I’m working on windows

>Solution :

You may try the following find and replace, in regex mode:

Find:    ^\D*(\d+(?:,\d+)?).*$
Replace: $1

Here is an explanation of the regex pattern:

  • ^ from the start of the line
  • \D* consume zero or more non digit characters
  • (\d+(?:,\d+)?) match and capture in $1 the first digit, with optional decimal
  • .* consume the rest of the line
  • $ end of the line

Here is a working demo.

Leave a Reply Cancel reply