How to use regex to extract specific data from text file

  1. Extract all data from the invoice attached (Only Invoice 1.pdf) with the assignment and Put it into Notepad .

Read the Value for Opening Balance from the Notepad and Write it into the Word File.

Send that word file to yourself using Gmail.

@Deepti_Kadam

Can you share the screenshot of the data you have?

usually Regex work as below for example

But it will vary, so share your notepad result, accordingly we can suggest

Thanks

Hey Deepti, you can use Nanonets cognitive OCR to extract “opening_balance” : NanoNets OCR - RPA Component | UiPath Marketplace

100 pages are free each month!

thanks I did the same way but what if the value is not present in text file then how to check it.

@Deepti_Kadam

You can first check as below

Use IF Condition
YourStringVariable.Contains(“Opening Balance”)

Then If exists use Regex else use your next steps

Hope this may help you

Thanks

thank you it is showing an error cannot convert to ‘System.Text.ReularExpressions.Match’

@Deepti_Kadam - Could you please share the screenshot of that activity and the error?

@Deepti_Kadam - Thanks for sharing. If could you show the regex activity …ie. text and pattern would be great…

I guess, error originates from there…

(?<=[O|o]pening [B|b]alance).* this expression is used in regex wizard builder activity

@Deepti_Kadam - You pattern does seems to be correct…If you are looking for handling cases, you choose Ignore Case as shown below…

Not sure, where exactly your Opening Balance value appears, check in the write Line regex(0).count returns anything.