Extract all the dates and all the amounts from a string

Need to extract all the dates and amounts mentioned in an extracted string.

Anyone can please help with this?

String Eg.: Everything in bold needs to be extracted

Crossword Tool
20/02/2020
Created form on 23/04/2020 at 3,400
Balance 12,000
Total 3,400

Date: 25/05/2020

If MyText is the string represented by your example, use System.Text.RegularExpressions.Regex.Matches(MyText, "\d{2}/\d{2}/\d{4}") to get all date matches.

Use System.Text.RegularExpressions.Regex.Matches(MyText, "((\d+,)+\d+)|((?=>at\s)\d+)|((?=>Total\s)\d+)") to get the amounts. This regular expression checks for numbers with commas first, and if none exist, then search for string "at " or "Total " to locate the amounts (in case the amounts do not contain a comma).

2 Likes

ExtractDates.xaml (7.5 KB)

Try this also.! @rahul9sharma

Thanks!

1 Like

Worked perfectly fine, Thanks!

Thanks for putting efforts in studio to make this file. Appreciate it! :slight_smile:

But, the text I gave was just an random example. The actual texts can be anything and can contain any number if dates and amounts at different places in string.

Thanks again!

1 Like

Hey @Anthony_Humphries

Could this be also modified for accepting the date format , dd-mmm-yyyy (eg, 29-Mar-2020) in the same expression?

Yes, but you would need to change it to System.Text.RegularExpressions.Regex.Matches(MyText, "(\d{2}/\d{2}/\d{4})|(\d{2}-\w{3}-\d{4})").

1 Like

Thanks a lot @Anthony_Humphries. That was accurate and helpful.

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