|
non-greedy regexp: msg#01123lang.ruby.general
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? Thanks -- tom@xxxxxxxxxxxxxxxxxxx remove 'spamfree.' to respond
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: ambiguity backtrack - accessors and persistent locals, Charles Hixson |
|---|---|
| Next by Date: | Re: non-greedy regexp, dblack |
| Previous by Thread: | [ANN] Sys::ProcTable 0.3.0, Daniel Berger |
| Next by Thread: | Re: non-greedy regexp, dblack |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |