Get decimal number with regex

Hello,

Always before a specific keyword I have a decimal number. I need to take these decimal numbers.
Example of the text: “1.398,17 Batch-No. 44444”
The key word is always Batch-No.
I try with this code but I’m taking only the 17. I can’t take the whole amount 1.398,17. Also the rest of the amounts.
Example of the code: Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript

Thanks in advance!

Hi,

Can you try the following pattern?

[\d\.,]+(?=\s+Batch-No)

Regards,

2 Likes

@Yoichi it’s working. Thanks!
But for example if I have 10 timees batch-no and 10 times before this keyword decimal amounts, it it possible to extract all these 10 decimal amounts at once?

Hi,

Probably yes, if I understand your needs correctly.
Can you try Matches activity? It returns IEnumerable<Match> and we can extract each result using for each activity.

Regards,

The problems is that I got a lof of other decimals in this file. It will extract too many that I don’t need them. I only need these decimal numbers which are before batch-no.

Hi,

Probably the above pattern will work in your case.
Can you share your data? It’s no problem if dummy data.

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.