On Tue, Jan 08, 2002 at 08:20:10PM -0800, Yitzchak Scott-Thoennes wrote:
> Now that someone has braved removing the quotes in the regex (which
> I was hoping would happen) I'll post my solution that does it the
> long way:
That's the way I went as well, although it makes some complications for the
rest of the solution.
> 82:
> -nl $,=":";print map/^"(.*)"$/?$1:$_,/\s*("[^"]*"(?=[\s#]|$)|[^\s#]+)\s*(?:#.*)?/g
>
> This should be easily beatable.
Here's my current solution, at 64:
-pl $_=join':',grep defined,/"([^"]*)"(?![^\s#])|([^\s#]+)|#.*/g
Originally I had $_.0 instead of defined, but I realized that that skips
empty fields, i.e. "". Is there a shorter way to test for defined?
BTW, (?=\s|#|$) is shorter than (?=[\s#]|$).
Ronald