Re: Right Associative Matching Example (for Docs)
Chris Babcock <[email protected]>
| Newsgroups | gmane.mail.spam.crm114 |
|---|---|
| Organization | ASCII King Games |
| Message-ID | <[email protected]> |
On Thu, 18 Dec 2008 22:04:49 +0100 Paolo <[email protected]> wrote: > On Thu, Dec 18, 2008 at 10:46:36AM -0700, Chris Babcock wrote: > > > match (:: :a:) /(?ir:":*:e:".+?"([[:print:]]+?)".+?\n)/ > ... > > match (:: :a:) /(?ir:":*:e:".+?"([[:print:]]+?)".*?\n)/ > > yep, that does match last field - however I get no difference with > just '?i:'; also, simple > > /":*:e:".+?"([[:print:]]+?)".*?\n/ > > seems to do the job as well, for last non-null-value-in-quotes, > whereas > /":*:e:".+?"([[:print:]]+?)".*\n/ > > would yield the 1st such value after :*:e:. Is that a bug then? Both produce the same results for the exterior match, but the behavior I obviously expected based on the docs was for the first "+?" to be 'lazier' than the second as a default, this being the behavior to be altered by the 'r' switch. > > The problem is that I was overcompensating for a bad habit. I've > > been trying to break the habit of using * when I mean +. If you > > don't have a comma or some other character at the end of the line > > then the closing quotes go to satisfy the ".+?" and the comma > > becomes the last 'field'. > > unfortunatly CSV isn't that simple to parse I wasn't expecting as much to parse CSV files generically as to simplify a practical application for something mentioned in the docs. When there is a new line available as a deliminator, it is too valuable to ignore. A more practical application for the feature (if it worked as expected) would be for parsing text where the new line is not a consistent feature, for example HTML tables. Chris ------------------------------------------------------------------------------ SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/