#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    2
    Rep Power
    0

    Grab multiple lines of string


    Trying to write a reg expression to grab info from a customer invoice. Below is the string I'm grabbing from the document via OCR.

    Customer: RD Dock, LBD 1346
    Clermont
    Service Location

    I'm trying to capture "RD Dock, LBD 1346 Clermont" but for the life of me can't figure out how to grab the next line containing "Clermont".

    Any advice??

    Thanks,
    Lo
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,997
    Rep Power
    9397
    Once you get "RD Dock, LBD 1346" all you have to do is append something that accepts a newline character and then everything (?) on the next line. Like
    Code:
    Customer: (.*)
    becomes
    Code:
    Customer: (.*\s+.*)
    (assuming that you have . not matching newlines, as is typically the default behavior)

    You'll then want to replace the newline character, be that \r or \n or \r\n, with a single space.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    2
    Rep Power
    0

    Still need help


    I sort of got it to work but still having one problem. Looking at some of the different invoices the Customer line is sometimes one line and other times contain two lines of code.

    Customer RD Dock, LBD 1346
    Clermont
    Service Location North Florida

    Customer: NRC, MSP 1488
    Service Location South Florida

    I need a reg expression that will capture everything between customer and service. Needed output of these two examples would be as follows.

    RD Dock, LBD 1346 Clermont

    NRC, MSP 1488

    I tried your suggestion of .*\s+.* and the following result was returned.

    Customer RD Dock, LBD 1346

    Service Location North Florida

    Please advise.

    Thanks,

    Lo
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    spaceBAR Central
    Posts
    229
    Rep Power
    42

IMN logo majestic logo threadwatch logo seochat tools logo