Regular Expressions 101

Community Patterns

1...34567...132

ParsingAmazonInvoice

1

Regular Expression
PCRE2 (PHP >=7.3)

/
(Final Details for Order #)([-#0-9]{19})\R*(Order Placed\:\s)(([JFMASOND][aepuco][nbrylgptvc]).+?)([123][0-9],\s)(20[0-2][0-9])(.+?)(Amazon\.com\sorder\snumber\:\s\2)(.+?)(Order\sTotal\:\s(\$?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$)).*?(\r|\n).*?(Shipped\son\s)(([JFMASOND][aepuco][nbrylgptvc].+?)\s([123][0-9],)\s(20[0-2][0-9])).*?(\n|\r).*?(Items\sOrdered\s\dof\:(.+?))(Sold\s\by\:\s)(.+?)(Price\s)(\$?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$).+?(Condition\:\s)(New|Used)
/
gm

Description

Goes through a Plain text derived from a PDF capturing the order number, the items, the order and ship dated and the costs.

Submitted by anonymous - 3 years ago