logo       

Re: non-greedy regexp: msg#01127

lang.ruby.general

Subject: Re: non-greedy regexp

Hi --

On Tue, 13 Aug 2002 dblack@xxxxxxxxxxxxxxxxxxxx wrote:

> To do what you were trying to do, try this:
>
> irb> "http://www.x.com/y/z.html".sub(%r|/[^/]+/?\.html$|, '')
> "http://www.x.com/y";

Whoops, having seen Mauricio's I now see a meaningless "/?" has
slipped into mine :-)


David

--
David Alan Black
home: dblack@xxxxxxxxxxxxxxxxxxxx
work: blackdav@xxxxxxx
Web: http://pirate.shu.edu/~blackdav




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise