[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string search from back to front?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 30 Oct 2013 16:08:17 +0200
s='the quick brown fox jumps over the lazy dog'
w='the'
j,k=s:reverse():find(w:reverse()) --> 10 12
j,k=#s-k+1,#s-j+1 --> 32 34
print(s:sub(j,k)) --> 'the
Just turn that into a function, and there you are.
2013/10/28 <meino.cramer@gmx.de>:
> Hi,
>
> in the PIL 2ed I didn't find a way to search from the end of a string
> to the beginning. There is a way to specify an offset from the back
> with a negative instead of a positiv, but from that specified point
> the search goes from 'left to right' or 'front to back'.
> Is there real;y no equivalent to "RIGHTSTR()" in lua or did I overlook
> something ?
>
> Best regards,
> mcc
>
>
>
>