[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: gsub bug? 2 results from anchored gsub
- From: Matthew Wild <mwild1@...>
- Date: Mon, 27 Jul 2015 13:05:03 +0100
On 27 July 2015 at 03:40, Daurnimator <quae@daurnimator.com> wrote:
> I want to ensure that a string always ends in a single "/".
> If it has more than one, the extras should be removed
> If it has none, a "/" should be appended.
>
> "/*$" should match all the '/' at the end of the string, and replace
> them with a single "/".
> I got an unexpected result:
>
> > ("d//"):gsub("/*$", "/")
> d// 2
FWIW because of this my approach for this (e.g. in path/URL
normalization) is generally s:gsub("/+$", "").."/"
Regards,
Matthew