Re: Regex Help?

2011-10-10 Thread Chris
On Sat, Oct 8, 2011 at 1:19 PM, S. Dale Morrey wrote: > 12137 HOLIDAY PENGUIN FIGURINES 335 9.95 4.25 5.95 1 PR If some (or all) of your fields are fixed width, the width qualifier {n} operator might be useful (shown here pulling out the $item and $desc fields): ($item, $desc, $page, $retail,

Re: Regex Help?

2011-10-10 Thread Doran L. Barton
On Monday, October 10, 2011 09:26:19 AM ijason wrote: > Nice if as an additional note if you decide to concatenate multiple > inserts into a single insert be mindful that there is a 50k char limit > with MySQL inserts so you will need to check your length periodically to > make sure you don't ex

Re: Regex Help?

2011-10-10 Thread ijason
On 10/10/2011 9:15 AM, Doran L. Barton wrote: > On Monday, October 10, 2011 09:04:38 AM ijason wrote: >> $db->do("insert into tablename (column names) values >> ('$line[0]','$line[1]'...)"); > This is cool, but may I suggest you instead hawk the parameterized use of > DBI::do: > > $db->do('IN

Re: Regex Help?

2011-10-10 Thread Doran L. Barton
On Monday, October 10, 2011 09:04:38 AM ijason wrote: > $db->do("insert into tablename (column names) values > ('$line[0]','$line[1]'...)"); This is cool, but may I suggest you instead hawk the parameterized use of DBI::do: $db->do('INSERT INTO tablename (col1, col2, ... ) VALUES (?, ?,

Re: Regex Help?

2011-10-10 Thread ijason
On 10/8/2011 3:58 PM, Charles Curley wrote: > On Sat, 8 Oct 2011 13:19:43 -0600 > "S. Dale Morrey" wrote: > >> 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

Re: Regex Help?

2011-10-08 Thread Richard Esplin
Tools to save you lots of trouble with RegExes: http://gskinner.com/RegExr/ http://txt2re.com/ Enjoy! Richard On Saturday October 8 2011 13:19:43 "S. Dale Morrey" wrote: > Ok I'll admit it, I suck at regex. > Unfortunately, I now have the task of importing a customers catalog > price list in

Re: Regex Help?

2011-10-08 Thread Charles Curley
On Sat, 8 Oct 2011 13:19:43 -0600 "S. Dale Morrey" wrote: > 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

Re: Regex Help?

2011-10-08 Thread Doran L. Barton
On Saturday, October 08, 2011 01:49:36 PM Steve Meyers wrote: > /^([0-9]+) (.+) ([0-9]+) ([0-9.]+) ([0-9.]+) ([0-9.]+) ([0-9]+) ([A-Z]+)$/ This is a lot simpler if you use PCREs (e.g. \w+, \d+, etc.). You kind of already are (+ is a PCRE operator). -- Doran L. Barton - Hypermoo Inc. - - 801-520

Re: Regex Help?

2011-10-08 Thread Jeff Anderson
You probably don't even need a regular expression at all. Just split on whitespace. Then loop over the fields. From the second field onward (the description), add a space for the delimiter to your output. Until you hit a number. Then use commas. As long as none of the description words start

Re: Regex Help?

2011-10-08 Thread Ed Felt
On Oct 8, 2011 1:49 PM, "Steve Meyers" wrote: > > On 10/8/11 1:19 PM, S. Dale Morrey wrote: > > Item Item Description Page # Retail Member Wholesale Pkg > > 12137 HOLIDAY PENGUIN FIGURINES 335 9.95 4.25 5.95 1 PR > > Can there be more than one whitespace in between fields? If so, add a + > after

Re: Regex Help?

2011-10-08 Thread Alan Young
On Sat, Oct 8, 2011 at 13:19, S. Dale Morrey wrote: > 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 If the last fields are well known/defined you could do something like (based entire

Re: Regex Help?

2011-10-08 Thread Steve Meyers
On 10/8/11 1:19 PM, S. Dale Morrey wrote: > Item Item Description Page # Retail Member Wholesale Pkg > 12137 HOLIDAY PENGUIN FIGURINES 335 9.95 4.25 5.95 1 PR Can there be more than one whitespace in between fields? If so, add a + after each space. I'm also assuming that the unit is always uppe

Regex Help?

2011-10-08 Thread S. Dale Morrey
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 wh

Re: Regex Help?

2011-10-08 Thread Wade Preston Shearer
On 8 Oct 2011, at 13:19, S. Dale Morrey wrote: > 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 cou