From: David Alan Black Date: 2002-08-05T11:37:12+09:00 Subject: Re: Regex question Hello -- On Mon, 5 Aug 2002, Gavin Sinclair wrote: > Folks, > > Just a quick one. > > md = /\..*?$/.match "dotslash.tar.gz" > md[0] # -> ".tar.gz" > > I expect md[0] to be ".gz", because the question-mark in the regex tells * > not to be greedy. Can anyone enlighten? It will still find the first '.' from the left, and then be non-greedy. In other words, non-greediness affects how much gets consumed to the right in a given match. Try this: /\.[^.]*$/ which forces the match to start at the right-most '.' on the line. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav