From: "David A. Black" Date: 2004-09-19T08:30:23+09:00 Subject: Re: Method improvement request .-- Hi -- On Sun, 19 Sep 2004, Charles Hixson wrote: > That's a very interesting rewrite of the parse1 match patterns. > It's a bit more complicated than that, e.g., at the match boundary > apostrophe's aren't a part of the middle, but in the middle (of the > middle) they are. Think about 'don't'. Think about "'tis" :-) > P.S.: Does scan keep recycling it's pattern, or would I need to replace > it with (an elaboration of) > chunks = line.scan(/^((\W*)(\w*)(/W*)s+/)$).flatten scan keeps recycling its pattern, but note that ^ and $ will be included each time. Note also that ^ and $ apply to lines, not the entire string. Thus: $ ruby -e 'p "a\nb\ncde\n".scan(/./)' ["a", "b", "c", "d", "e"] $ ruby -e 'p "a\nb\ncde\n".scan(/^.$/)' ["a", "b"] You can use \A and \Z to indicate start and end of string (or \z to match end-except-for-possible-newline). David -- David A. Black dblack@wobblini.net