From: Charles Hixson Date: 2004-09-19T08:14:17+09:00 Subject: Re: Method improvement request .-- James Edward Gray II wrote: > On Sep 18, 2004, at 5:04 PM, James Edward Gray II wrote: > >> What about something like: >> >> def parse1(chunk) >> if chunk =~ / ^([^-A-Za-z0-9]*) # pre-match >> (.*) # middle > > > Sorry, that probably needs to be: > > (.*?) > > My bad. > > James Edward Gray II That would only work if the postmatch pattern were included in the same pattern as the prematch, thus: if chunk =~ /^([^-A-Za-z0-9.]*)(.*?)[^-A-Za-z0-9.]*)$/ But that's a good idea. I hadn't realized it was so easy to specify that a piece of a pattern was non-greedy. Thanks. > >> ([^-A-Za-z0-9]*)$ # post-match >> /x >> a, b, c = $1, $2, $3 >> end >> end >> >> Does that give you some ideas? >> >> James Edward Gray II >> > > >