Pulling substring or index of a 9 digit number in a block of text

i am using OCR to read through driver’s licenses and i need to pull the number off of them. problem is that the scan quality is not universal so finding the index of the preceding characters is not working all the time. but the number itself seems to pretty accurate.

what is the best way to scan through the text and find the 9 digit number in the text block then pull that substring out?

thanks!!

using regex and matches

1 Like

@Jason_Dossett You can use regular expression to get 9 digits from the text refer this Regex for your reference

1 Like

If you have text then use regex. If the data you require is of 9 digits then you can use this regex - \d{9}. This would help you in retrieving the numbers from any given text easily.

1 Like

yeap matches using regular expressions. i did not even know about the matches activity.

in order to get the result out of whatever variable you assign to matches output you have to treat it as an array so

licensenum= matchesarray(0).tostring

\d{9} yoinked out the number for me also [0-9]{9} would have worked but was less elegant in my opinion and would have covered fewer numeric options.

thank you everybody.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.