Pattern error while using regex for data extraction

I am trying to extract data from pdf using Regex101
Eg: I want to extract “376 11” from this text “Care-ER 25 938 39 1 45 376 11”
I tried this regex which is giving me the correct value
(?<=Care-ER\s\d\d\s\d\d\d\s\d\d\s\d\s\d\d\s)(\d+)?(\s)?(\d+)?

the values between Care-ER and 376 11 can be more or less
so I tried dynamic regex
(?<=Care-ER\s(\d+)?(\s)?(\d+)?(\s)?(\d+)?(\s)?(\d+)?(\s)?(\d+)?(\s)?)(\d+)?(\s)?(\d+)?

But it gives me a Pattern error: +A quantifier inside a lookbehind makes it non-fixed width

Need help in solving this.

1 Like

Hello @waseem,

Tell me this, will it always be last Five Digits??

Cheers

Hi @waseem,

if so you can use this Pattern \d+\s\d+$

Cheers
@waseem

Depends actually these are three amount Care-ER 25 938 39 1 45 376 11
25,938.38 1.45 376.11
when I convert from pdf to text , and . is replaced by space.
I need to extract the last amount only, it can be large amount as well, same goes for the values which are first and second.

Hi @Pradeep_Shiv, did you find any solution for above scenario.
I need to implement this.
Kindly help me out.

If we can assume that all amounts end with two decimals, you can use the following pattern:

(?<=Care-ER (\d{1,3} (\d{3} )*\d{2}) (\d{1,3} (\d{3} )*\d{2}) )(\d{1,3} (\d{3} )*\d{2}\b)

Hi @waseem,

Did you find the solution?