You are viewing limited content. For full access, please sign in.

Question

Question

Pattern matching to apply dd/mm/yyyy for date format

asked on December 7, 2015

Hi all,

I want to retrieve the Invoice Date and I have used the OmniPage Zone OCR as a process in QuickFields. The objective behind using the PatternMatching is that the invoice is not properly calibrated and I cannot assume that the value of the Invoice Date will be always fixed at the same position.

I have added the PatternMatching as I want to evaluate the Invoice Date to dd/mm/yyyy. Please find screenshot of how I write my pattern expression.

While testing the pattern, it returns nothing in the result value. Can somebody please help me out?

 

Thanks to advise.

Kind Regards,

Sheila

0 0

Replies

replied on December 7, 2015

Hi Sheila,

I'm not convinced your method is the best approach because it assumes the month and day will always be 2 digits. Will the date be 01/01/2015 or 1/1/2015, for example?

However, I presume you've considered all of that, in which case the fix for you pattern is this:

(?:Invoice)\s*(?:Date)\s*:\s*([0-9]{2}/[0-9]{2}/[0-9]{4})$

An alternative for the shorter date (1/1/2015) could look like:

(?:Invoice)\s*(?:Date)\s*:\s*([0-9]{1,2}/[0-9]{1,2}/[0-9]{4})$

Hope this helps.

-Ben

replied on December 7, 2015

Hi Sheila,

Your scripts assumes the month and day will always be 2 digits. Will the date always be 01/01/2015 or could it also be 1/1/2015, for example?

However, I presume you've considered all of that, in which case the fix for you pattern is this:

(?:Invoice)\s*(?:Date)\s*:\s*([0-9]{2}/[0-9]{2}/[0-9]{4})$

An alternative for the shorter date (1/1/2015) could look like:

(?:Invoice)\s*(?:Date)\s*:\s*([0-9]{1,2}/[0-9]{1,2}/[0-9]{4})$

Hope this helps.

-Ben

0 0
replied on December 7, 2015

Couldn't you just use \d+/\d+/\d+ to get the date with whatever you need to put in front of it to anchor. That way you will get either 1 or 2 digit day/month.

The problem you will have with getting it into a dd/mm/yyyy format is that the text will not be treated as a date because it is a string of text. Here is a conversation/question similar to this one that may help. http://answers.laserfiche.com/questions/86642/Workflow--Apply-Format-to-Date-ddMMyyyy#86661

0 0
replied on December 7, 2015

Hi,

Thanks a lot for the response. But, I am unable to retrieve the Invoice Date. Please find a screenshot for the zoning I have placed to capture the Invoice Date. As you can see, the invoice is not well calibrated as the value of the Invoice is not properly aligned with its label. Therefore, I presume that I will enclose all the 3 labels.

Thanks to advise

Kind Regards,

Sheila

0 0
replied on December 7, 2015

Using the Zone OCR actually makes it easier. Try just using \d+/\d+/\d+ as the pattern match for that Zone.

0 0
replied on December 7, 2015

If you're going to enclose a single date with a Zone OCR then Darrell's idea looks the best. It's far more simple. It could possible to enhanced to check for spaces but they may turn out to be minor exceptions.

0 0
replied on December 7, 2015

I have used the Zone OCR as process and the Invoice Date is returning blank.

I prefer to select the 3 lines as I am uncertain on whether the position of the invoice date can be different in other invoices. I have assumed that the position of the invoice date can changed a little bit on the invoice.

0 0
replied on December 8, 2015 Show version history

Sheila, in the output pane, you should see what the Zone OCR picks up.  From what I can in the background (on the invoice page) it looks like "Invoice Date" is unlikely to match with the date in the way the RegEx expects. 

Can you copy and paste that here? If I can see what's being read, I could debug the problem.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.