Regex, extraction problem

Good morning, from the following text I try to make matches with regex, but for some reason, it does not work, for example I want to get the number 835,80 with the following expression,

(?<=Importe\sTotal:\s(.?(?=\s))\s)(.?(?=\s))

this expression, I take all the groups from the total amount …

835,80
21,00
175,52
0,00
0,00
1.011,32

I would like to know the regex expression to capture these numbers of expression form without using GROUPS

this is the text I use in regex, extracted from a pdf

03/19/2021 13:27:35 => [Debug] Main Executing
03/19/2021 13:27:35 => [Debug] ReadPDF Executing
03/19/2021 13:27:35 => [Debug] Read PDF Text Executing
03/19/2021 13:27:35 => [Debug] Read PDF Text Closed
03/19/2021 13:27:35 => [Debug] Multiple Assign Executing 662AF000004 Salicru SPS one 1100VA / 600W 4xSchuko 2xRJ11 USB 1,00 66,50 0,00 66,50 1011,32 Base Imponible +LPI IVA Cuota IVA Recargo Cuota Recargo Importe Total: EUR 835,80 21,00 175,52 0,00 0,00 Forma de pago: RECIBO DOMICILIADO A 20 D-B2B Vencimientos: 06/04/2021 1.011,32 EUR Dirección de giro:
03/19/2021 13:27:55 => [Debug] Write Line Closed
03/19/2021 13:27:55 => [Debug] Write Line Executing
03/19/2021 13:27:55 => [Debug] ReadPDF Closed

Thanks

@joseantonio

If you need only the first result from the multiple result, then try with
MatchesResult Variable(0).ToString

This will always give you the first result

Hope this may help you

Thanks

@joseantonio - Please give the exact text, will share the regex pattern …

this text
Salicru SPS one 1100VA / 600W 4xSchuko 2xRJ11 USB 1,00 66,50 0,00 66,50 1011,32 Base Imponible +LPI IVA Cuota IVA Recargo Cuota Recargo Importe Total: EUR 835,80 21,00 175,52 0,00 0,00 Forma de pago: RECIBO DOMICILIADO A 20 D-B2B Vencimientos: 06/04/2021 1.011,32 EUR Dirección de giro:

@joseantonio - thanks…and you want only 835,80 right?

My intention is to avoid the use of groups, that’s why the text does not have line breaks, only spaces, but I don’t know why it takes me so many groups

835,80
21,00
175,52
0,00
0,00
1.011,32

I want to extract that from the text without creating groups

Why without groups…do you have any reason ??

have a robot, which extracts data from multiple pdfs, and I want to use the same form for each type of document, the only one that gives me problems is this, so I want to avoid groups, I understand that although the expression is long, it should be able to capture no group right?

@joseantonio - i don’t think without groups you can’t capture all the amount in one shot…You may need 6 different regex for your case

If your pdfs follows the same pattern…you can get one regex pattern and write all the amount in shot in 6 different column in excel easily…

Yes, I want to use 6 different expressions, my problem is that trying to capture the first amount, it takes everything until the end of the text

@joseantonio - Won’t this serve the purpose…

835,80 - Regexvar(0).groups(1).tostring
21,00 - Regexvar(0).groups(2).tostring
175,52- Regexvar(0).groups(3).tostring
0,00 - Regexvar(0).groups(4).tostring
0,00 - Regexvar(0).groups(5).tostring
1.011,32 - Regexvar(0).groups(6).tostring

@joseantonio - you can get the amounts like this…

but what would be the expression to capture only 1,001,32 for example?

I would like to do nothing groups and do 6 different … but they do not work for me

This is what you asked initially?

Now this??

Your goal is extract all the 6 amounts right??? i am saying you can do with groups…and you just have to get the different groups to print the required amounts…i also shared the example above…you dont want to do in the effective way??

It may not be the best way to do it with 6 different expressions, but it is the only way to unify all the different types of documents that I have, that’s why I was asking,

Sorry, i didnt get you??

Your documents have same text pattern right?? I would like to see…could you please share the couple of more text formats like the one you shared above…i will put it in the text file and show you how to handle multiple documents…

Regex groups or 6 different pattern – does not matter , if your input text doesnt follow the same pattern Regex won’t work even if I give 6 different regex…that’s my point…hope you get it…

I understand you, but the same with the translator I think that I am not understood, the project that I have depending on the document, uses several regex expressions to extract data, with all the documents I have not had a problem, it extracts the regex expression from a database without problem, I use 6 expressions for each document, and so I always make sure of the same structure, the problem, I have it in the text that I have passed before, for some reason I am unable to create 6 expressions to follow the same process, that’s why help. I don’t know if you understand me … still thank you

1 Like

@joseantonio - sorry didn’t follow you…

But I will give you 6 pattern once I am back…thanks

I apreciate it, thanks