Regex- extracting data from text file

Hi!!!
“8221113 W91451930 2023-08-25”
From this, I need the 1 st set of no.
And then the date in separate Regex
“Total hors T.V.A. 2 712,23 EUR”
“Total incl. T.V.A. 3 254,68 EUR”
I only need amount from this…
Can anyone please help me
Thanks!!!

image

(?<=T.V.A. )[0-9, A-Z]+

Hi @abivanth.r

Check the below regular expressions to extract the amount from the Input,

\d+\s?\d*\,?\d*

image

To extract the 1st set of no’s, use below one,

\d{7}(?=\s+[A-Z]+)

image

To extract the date from the input, check below one,

\d{4}\-\d{2}\-\d{2}

image

Hope it helps!!

Yes bro… But i need to take them separately.

How will you get the Input is it coming from any Text file or you are storing the input separately in different variables.

Could you be more specific… Provide your proper input then we will provide regex for that.

Hope you understand!!

@abivanth.r

Input=“8221113 W91451930 2023-08-25”

Str_Out=System.Text.RegularExpressions.Regex.Match(Input,“\d{6,}(?=\s[A-Z]+)”).Value
Input= “Total hors T.V.A. 2 712,23 EUR”
“Total incl. T.V.A. 3 254,68 EUR”

MatchCollection=System.Text.RegularExpressions.Regex.Matches(Input,“\d+,\d{2}”)

MatchCollection Datatype=IEnumerable(Match)

And take for loop to get the Matches items

image
image

I am converting a pdf into text and using regex i am storing data in a datatable and printing in excel

Hi Bro!
I can’t understand… how do i use this in a flow?

Hi bro!
This is helping. I need the integer amount value only. regex formulae taking “EUR” tooo.

Okay @abivanth.r

Check the below one,

- Assign -> Input = "8221113 W91451930 2023-08-25
                    Total hors T.V.A. 2 712,23 EUR
                    Total incl. T.V.A. 3 254,68 EUR"

- Assign -> Price1 = System.Text.RegularExpressions.Regex.Match(Input.toString,"(?<=hors.*)\d+\s?\d*\,?\d*").Value

- Assign -> Price2 = System.Text.RegularExpressions.Regex.Match(Input.toString,"(?<=incl.*)\d+\s?\d*\,?\d*").Value

- Assign -> Date =  System.Text.RegularExpressions.Regex.Match(Input.toString,"\d{4}\-\d{2}\-\d{2}").Value

- Assign -> Numbers =  System.Text.RegularExpressions.Regex.Match(Input.toString,"\d{7}(?=\s+[A-Z]+)").Value

Output -
Price1 Variable gives the 2 712,23
Price2 Variable gives the 3 254,68
Date Variable gives the 2023-08-25
Numbers Variable gives the 8221113

Hope it helps!!

@abivanth.r



If you have Multiple matches in an item then please follow this approach

new.xaml (10.8 KB)
here is the workflow ,Do Let me know if it works

image

(?<=T.V.A. )[0-9, ]+

image

(?<=[A-Za-z ].+(hors T.V.A. ))(\d\s\d+,\d+) pattern to get first amount

(?<=[A-Za-z ].+(incl. T.V.A. ))(\d\s\d+,\d+) pattern to get second amount

yeah… amount worked

Date de livraison: “2023-08-25”
Can you help me get the date from this

image

Check the below workflow for better understanding… @abivanth.r

Sequence.xaml (8.0 KB)

Hope you understand!!

Hey @abivanth.r
try use this:

first set of numbers
System.Text.RegularExpressions.Regex.Match(yourInputStringVariable, "^\d+").Value
extracting the date in YYYY-MM-DD format
System.Text.RegularExpressions.Regex.Match(yourInputStringVariable, "\d{4}-\d{2}-\d{2}").Value
extracting the amounts
System.Text.RegularExpressions.Regex.Match(yourInputStringVariable, "\d[\d\s]*,\d{2}(?= EUR)").Value

i have another date from my text which i don’t want…
Can we take the date from this line"Date de livraison: 2023-08-25"