Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

E.g.:

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

0,00
45,11
39,90

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

PS:
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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading