-2

Goal: Trying to capture just the Total Number (95,600.91) however on some documents it shows with no spaces and need to create regex that looks for scenario with spaces and scenario with no spaces but returns 1 capture group.

Total Sample I: ========================================== 95,600.91 .00 95,600.91

Total Sample II: ========================================== 95,600.91.0095,600.91

My Regex For The Total: (?:==\s+\d.*?\.00)(\S+)|(?:==\s+\d.*?\.00\s+)(\S+)

Sample Text:

DM20066906 2020-06-22 WHOLE FOODS-WEST       12.37-    .00   12.37- 
DM20067812 2020-06-22 WHOLE FOODS-WEST       132.26-   .00   132.26-
DM20068372 2020-06-12 POMME D'API            143.72-   .00   143.72-
DM20069488 2020-06-25 WHOLE FOODS EAST       3.75-     .00   3.75-  
DM20069594 2020-06-12 J HOLTMANN             367.50-   .00   367.50-
DM20069986 2020-06-10 GOOD N NATURAL         210.00-   .00   210.00-
DM20079015 2020-07-03 VPFP PROGRAM FEES      641.32-   .00   641.32-

========================================== 95,600.91 .00 95,600.91

Printed on 2020-07-07 at 12:49
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563

1 Answers1

0

Trying making the whitespace after .00 optional with \s*

(?:==\s+\d.*?\.00)\s*(\S+)
brice
  • 1,801
  • 1
  • 10
  • 15
  • This worked for me. Looks like the \s* was what I was missing in my regex. My understanding is the \s* must mean the space is allowed but not necessary right? – David Kameka Dec 14 '20 at 01:03
  • yes. The `\s*` can be read as "a whitespace character repeated 0 to many times" – brice Dec 15 '20 at 18:52