Just a quick note to add to Ovid's fine comments.
You can use ([^,]+?) to have the best of both worlds (robust and specific as well as not being so greedy as to suck up the trailing white space before the \s* has a chance to get it.
You can also get fancier and help the regex engine match quicker by doing something like /^\s*([^,]*[^,\s])\s*,/, which (I think) will reduce the amount of backtracking possible (is it called "forwardtracking" in the case of non-greedy regex elements? ;> ). Note that this, like the last ones, doesn't match empty values.
You can support empty values with /^\s*((?:[^,]*[^,\s])?)\s*,/, but then you are going a long way for what may be little benefit.
In reply to Re: Regexp glitch while parsing record in CSV
by Anonymous Monk
in thread Regexp glitch while parsing record in CSV
by greenhorn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |