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

Question

Question

Reg Expression Extract the Last 9 Digit Number from a Line

asked on September 18, 2017

Hi I would like to get the Last 9 Digit # from the

Reg Exppression Extract the Last 9 Digit Number from  a Line

 

Ex

CUST CODE: GP00300-01 INV $ :  141206175 

 

I Need to get 141206175. Please help.

0 0

Answer

SELECTED ANSWER
replied on September 18, 2017

Hi Ganesa,

That Regex should get the last 9 digits from the line? the \d{9} will find the 9 numbers and the $ will target the end of the line.

Are you saying that the OCR will return more results along that line or overall? you could always try this one if that's the case - INV\s[#|$].*?(\d{9})

This will find your INV and any blank space between the '$' or '#' and should return the first matching 9 numbers afterwards.

4 0

Replies

replied on September 18, 2017 Show version history

Hi Ganesa,

Try either of these - (\d{9}$) OR \d{9}$

Providing you are always looking for 9 Numbers, it should work.

Regards,

Aaron

0 0
replied on September 18, 2017

Hi Aaron,

 

Thanks for the reply, It will help to get the 9 Digit number, but unfortunately there are in more areas 9 Digit numbers are there... I need to extract the 9 Digit number from the particular line 

CUST CODE: GP00300-01 INV $ :  141206175 some times the OCR'ed is capturing as 

CUST CODE: GP00300-01 INV # :  141206175 

 

Basically My Invoice is shows as 

CUST CODE: GP00300-01 INV # :  141206175 

0 0
SELECTED ANSWER
replied on September 18, 2017

Hi Ganesa,

That Regex should get the last 9 digits from the line? the \d{9} will find the 9 numbers and the $ will target the end of the line.

Are you saying that the OCR will return more results along that line or overall? you could always try this one if that's the case - INV\s[#|$].*?(\d{9})

This will find your INV and any blank space between the '$' or '#' and should return the first matching 9 numbers afterwards.

4 0
replied on September 18, 2017

Thanks Aaron.... You saved my time.... Works perfect

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

Sign in to reply to this post.