[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: reverse find
- From: Torsten Karwoth <agonizer@...>
- Date: Wed, 25 Jan 2006 20:38:49 +0100
> Is there a library function for a reverse find, or do I have to do it
> manually as in:
>
> -- untested
> i = 0
> do
> i = i - 1
> p = string.find(s, ".", i, true)
> while (p == nil and i ~= -string.len(s))
>
> (I'm searching for the file extension, and there may be other dots in
> the filename)
>
> Brian
With lua 5.1 string.match:
> =string.match("foo.bar.dot.lua","^.*(%..*)$")
.lua
>
=string.match("another.filename.with.extension.as.extension","^.*(%..*)$")
.extension
HTH,
Torsten