lua-users home
lua-l archive

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


I don't think that there is (and agree it would be useful).

I ended up doing the following in my code:
        --------------------------------------------------------------------
--
        -- Convert all non-alphanumerics to have a "%" escape character, to
        -- ensure that Lua doesn't interpret them as special characters.
        -- However, this means that any checks in the following code for
        -- non-alphanumerics must check for %[char].
        --------------------------------------------------------------------
--
        interest = Text:makeSafe(interest)
        gsub(document, interest, ...)
----------------------------------------------------------------------------
--
function Text:makeSafe(text)
    return gsub(text,
                "([^%w%s])",
                function(nonAlphaNum)
                    return("%"..nonAlphaNum)
                end)
end

John

----- Original Message -----
From: "Steve Dekorte" <steve@dekorte.com>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: Wednesday, November 14, 2001 2:45 AM
Subject: gsub without patterns


>
> Is there a way to use gsub that doesn't treat the first string as a
> "pattern" and just does a straight substring replacement? (Like the
> plain option in strfind) If not, I think this would be a useful addition.
>
> Steve
>
>
>