Help with RegEx commands to capture data from zonal OCR correctly

  • 5.3K Views
  • Last Post 26 October 2018
  • Topic Is Solved
mmcrob posted this 22 October 2018

Hi There,

New to DocNav and configured a workflow where the customer needs to use a date read in the format of dd/mm/yy to save the file to a path of %other zone%\%yy%\%mm%\

This works fine by reading the whole variable as one and then using %ocr_zone('/',3)% to get the year and %ocr_zone('/',2)% to get the month. However with the font sometimes it sees anything between 10-19 as 1 1 for 11 or 1 7 for 17 etc...

I'm looking to use the Regex option to trim out the 'spaces' and just keep the numbers, thus ending up with 03/12/18 being seen as 031218 rather than 03/1 2/1 8 then I can reference the month and year by using the 5th to 6th character and 3rd to 4th respectively... I'm new to RegEx and following the guides doesn't seem to be yielding the expected results.

Any help would be greatfuly appreciated.

Order By: Standard | Newest | Votes
luca.scarpati posted this 23 October 2018

Hi,

The RegEx that you find in the OCR area, is a RegEx that helps you get the right string (in your case the date).

So if it has some space between the numbers you need a little script like this: 

Dim zoneOCR

zoneOCR = Metadata.Values("YOUROCRVARIABLE")

zoneOCR = Replace(zoneOCR," ","")

call Metadata.SetValues("YOURNEWVARIABLE_WITHOUTSPACE",zoneOCR)

 

...now you can use your new variable in the folder field as you wrote above (e.g. %YOURNEWVARIABLE_WITHOUTSPACE('/',3)% and %YOURNEWVARIABLE_WITHOUTSPACE('/',2)% ).

 

I hope I was clear cool!

 

Best regards,

Luca

  • Liked by
  • mmcrob
mmcrob posted this 25 October 2018

Massively helpful thanks.

This will get the customer to the level they expect, but as I've looked this far they'd ideally like to store the final folder as %dd%.%mm%.%yyyy% - %weekday% - In order to workout the weekday I would need to use a VB script that would process the new variable as an actual date figure... Would you be able to point me in the right direction for such things?

And thanks once again

luca.scarpati posted this 26 October 2018

Hi,

 

more than welcome!

To take the right weekday I suggest you look at the function in VBS that returns it: https://www.w3schools.com/asp/func_weekday.asp ... you can insert the result in a new variable, called for example WEEKDAY.

 

Best regards,

Luca

mmcrob posted this 26 October 2018

Thanks Luca, you've been most helpful

  • Liked by
  • luca.scarpati
Close