lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Sun, Jan 25, 2009 at 8:41 PM, Sam Roberts <> wrote:
On Sat, Jan 24, 2009 at 4:56 PM, Vaughan McAlley <> wrote:
> OK, so to fix this problem I need to tell it exactly how many results
> I want. My function:
> function f(s)
>    if string.byte(s) == 42 then
>        -- do stuff if and only if s starts with "*"
>    end
> end


if string.find(s, "^*") then
 -- do stuff


if s:find("^*") then
 -- do stuff


If you're just testing a single character at the start, comparing to string.sub(s,1,1) - or s:sub(1,1) - seems like a more obvious route to take.