Regex Help?

S. Dale Morrey sdalemorrey at
Sat Oct 8 13:19:43 MDT 2011

Ok I'll admit it, I suck at regex.
Unfortunately, I now have the task of importing a customers catalog
price list into a database and I'm not sure where to begin.
I really think a simple regex could convert the whole thing to a CSV
and I could then import the CSV directly.

Here is an example of what I'm looking at.
Item Item Description Page # Retail Member Wholesale Pkg
12137 HOLIDAY PENGUIN FIGURINES 335 9.95 4.25 5.95 1 PR

As you can see all the fields are separated by whitespace, but then
again so are the individual words in the description.
In some descriptions there may be commas and so description text would
need to be quoted, in addition to having all the non-description
whitespace replaced with commas.  The last 2 fields should be a number
and a unit for instance 1 PR is 1 pair so 1,PR ought to be fine.

Ideally,the output should look like this.
12137,"HOLIDAY PENGUIN FIGURINES",335,9.95,4.25,5.95,1,PR

Where does one start with something like this?

More information about the PLUG mailing list