|
Re: non-greedy regexp: msg#01125lang.ruby.general
On Tue, Aug 13, 2002 at 03:28:26AM +0900, Tom Robinson wrote: > Hi, > > The following regexp is supposed to chop off the last / of a string > and all characters following it, but it seems to be ignoring the > non-greedy indicator (?): > > irb(main):001:0> "http://www.x.com/y/z.html".sub(%r|/.+?\.html$|, '') > "http:" > > The expected result should be "http://www.x.com/y". I thought this > was a bug but perl produces the same result, so what am I missing? > > Is there a better alternative to doing url parsing by hand? irb(main):001:0> "http://www.x.com/y/z.html".sub(%r|/[^/]+\.html$|,'') "http://www.x.com/y" -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Never trust an operating system you don't have sources for. ;-) -- Unknown source
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: non-greedy regexp, dblack |
|---|---|
| Next by Date: | Re: Handling forms on database driven websites, Chris Morris |
| Previous by Thread: | Re: non-greedy regexp, dblack |
| Next by Thread: | ruby-dev summary 17875-17964, TAKAHASHI Masayoshi |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |