Regular Expression Question

Hi,

I'm using OCR to translate a bunch of bills to text format, what i want to do is then transfer some of the data from the text outputs into a database.

I'm struggling with the reg exp part of it for identifying a payment was made:

Payment Voucher - Cheque                0.00       19.97        0.00
is the text and i want to extract the middle value (in this case 19.97)

As it can be payment voucher - S/O or many other things i can really only work on the word 'Payment'

How can i create a regexp to identify a row with the word payment then return the second integer it comes across (i.e. 19.97) in this case?

Cheers

Brendan
eyeisystemsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
Payment.*?\d\s+(\d+\.\d+)
eyeisystemsAuthor Commented:
Hi Ozo,

When i try that on regexr.com it brings back the full line, whereas i only want it to return '19.97'
käµfm³d 👽Commented:
Inspect capture group 1 from ozo's pattern. It container the 2nd value from the original string.
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

eyeisystemsAuthor Commented:
Hi käµfm³d,

Can you explain what you mean?

Cheers

Brendan
käµfm³d 👽Commented:
What tool are you using to execute this regular expression? Is it a text editor? A programming language?
eyeisystemsAuthor Commented:
Ive tested it on regexr.com (theres an editor you can use on that website to test regular expression) think its written in Java.

Cheers

Brendan
käµfm³d 👽Commented:
If you mouse over the text that is highlighted, you will see it mention "group #1". That is what I was referring to:

Screenshot

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shailesh ShindeLocalization Engineering & AutomationCommented:
Hi,

Try

Search : Payment.*?\d+\.\d+.*?(\d+\.\d+).*?\d+\.\d+
Replace: \1

Thanks,
Shail
Shailesh ShindeLocalization Engineering & AutomationCommented:
Hi,

Sorry, please ignore my answer.

Thanks,
Shail
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.