[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: how to gsub on the last occurence ?
- From: Duncan Cross <duncan.cross@...>
- Date: Wed, 13 Mar 2013 23:50:20 +0000
On Wed, Mar 13, 2013 at 11:19 PM, Laurent Faillie <l_faillie@yahoo.com> wrote:
> I would like to do
> string.gsub("blabla/in0_input", "_input", "_alarm")
>
> but I need to ensure the "_input" is really at the end of the string
Well, this will only work if you really do mean "at the end of the
string", and not just the last occurrence:
string.gsub("blabla/in0_input", "_input$", "_alarm")
The '$' character indicates that this search pattern only matches at
the end of the string.
If you DO mean the last occurrence (that may not be at the actual end
of the string), that will be trickier...
-Duncan