Link to home
Start Free TrialLog in
Avatar of Chris Jones
Chris JonesFlag for United States of America

asked on

help with regular expression to search string

Hello,

I have a string that I need to pull invoice related information out. I am trying to take this one step at a time and only get payment type information.

Here is an example of the text string
Invoice 1 12345
replace with
[Street Address) City) ST ZIP Code] G 0
Date To Ship To
[Click to select date] [Name] Same as recipient
[Address]
[City) ST ZIP Code]
Instructions
[Add additional instructions]
._.____.___-_I
1 Testl 3533.00 $33.00
1 TestZ 3514.00 $14.00
1 Test3 $20.00 3520.00
1 Test4 $99.00 $99.00
Subtotal $1024.00
Sales Tax 350.00
Shipping & Handling
Total Due By [Date]
Thank you for your business!
Tel: [Telephone] Email:
FOX: Web: [Web address]
v\E'l'IlIIllll" IIISJ‘HIUJIIHII
"(:I
[OI

Open in new window



i need to pull out seperating exmaple 1, test4, $99.00 , $99.00
1 Testl 3533.00 $33.00
1 TestZ 3514.00 $14.00
1 Test3 $20.00 3520.00
1 Test4 $99.00 $99.00
Subtotal $1024.00
Sales Tax 350.00

Open in new window

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

as this is likely line-based, I would start that part without regular expressions:

"scan" the lines one by one, check when you find this one:
._.____.___-_I  (not sure if that is the exact line ...)
then all the next lines are to be taken , until you get the one(s) starting with:
Subtotal
and also the next one starting with
Sales Tax

for each line there, I would indeed consider regular expressions to split into the different parts

1 Testl 3533.00 $33.00
can be "splitted" with a regex like this
(\d+)\s+(\w+)\s+(\d+.\d+)\s+\$(\d+.\d+)
Avatar of Chris Jones

ASKER

Thanks a bunch i will give this a try and report back.
Avatar of Rgonzo1971
Rgonzo1971

HI,

pls try
.*[.\d]{3,}

Open in new window

Regards
ASKER CERTIFIED SOLUTION
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is great stuff thank you so much for the awesome help i need to get better at REGEX