sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #19204
Re: [Question #232183]: [How To] set variable value from OCR numerics
Question #232183 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/232183
Status: Open => Answered
RaiMan proposed the following answer:
ok, thats new ;-)
we have to tweak the regex somehow
Supposing the max number is 999,999.00 ;-)
def getValue( text ):
m = re.match("[^0-9]*([0-9]*[,]?[0-9]*[.]?[0-9]*)", text) # the full value
try:
return float(m.group(1).replace(",", "")) # returns the found value as decimal
except:
print "could not extract number:", text
return -1 # returns -1 if any problems
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.