RegEx - Search for Word and Output Last Decimal Number on Line
I'm trying to use RegEx to parse the Total Hours working in a pay period from a PDF timesheet.
For example:
Total Overtime Hours: Total Hours: 2.2 1.0 1.0 3.5 5.0 12.7 Signature:
(?<=Total Hours:*(?:.*?( )+){6}).*
The Total Hours will always be the last number on the line that starts with "Total Hours:"
The above RegEx code works for most employees who work 5 days a week but breaks if they work more or less than 5 days as in the example below:
Total Overtime Hours: Total Hours: 2.2 1.0 1.0 3.5 5.0 6.3 19.0 Signature:
Any thoughts on the adjustments I can make to always grab the last decimal number of the row that starts with "Total Hours:"?
Thanks!
Comments
Post a Comment