Hello, hope one of you can see what I'm struggling with here.....;
I'm trying to extract value from a Zone OCR, using script sample from this link:
https://forum.scanshare.com/thread/script-extracts-a-part-of-a-string-that-corresponds-to-a-regular-expression/
The problem I have is first of all, I'm not experienced in scripting, but normally I understand enough to edit simple examples. This time I was unable to...
The problem I have when using the script is that it will find several matches from my RegEx in the zone, but I should have the value from the first hit. I get the value from the last hit instead, and I don't understand what to change in the script to make it only get the first match.
This is the script (so I have only made some minor changes):
--------------------
'###Variable definition area
'The user need to define the name of the metadata that is used as input sSearch = Metadata.Values("metadata")
sSearch = Metadata.Values("OCR_ZONE01")
'The user need to define the regular expression to be used on the metadata sPattern(1) = expression
DIM sPattern(1)
sPattern(1) = "\d\d[\,\.]\d\d[\,\.]\d\d"
FOR I = 1 TO 1
call Application.Log(20, "Pattern to search: " & sPattern(I))
call TestRegExp(sPattern(I), sSearch)
NEXT
Sub TestRegExp(sPattern, sSearch)
' Do the regular expression match
Dim oRE, oMatches
Set oRE = New RegExp
oRE.Global = True
oRE.IgnoreCase = True
oRE.Pattern = sPattern
Set oMatches = oRE.Execute(sSearch)
Dim oMatch
For Each oMatch In oMatches
call Application.Log(20, "Find part: " & oMatch.Value)
call Metadata.SetValues("PART_OCR_ZONE01",oMatch.Value)
Next
End Sub
--------------
Anyone have an idea?
Thanks in advance
Best regards, Anders Hantveit
Senior System Engineer, MCS, PRS and IMS ## Konica Minolta Business Solutions Norway AS