lua-users home
lua-l archive

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

The way I usually deal with this is either by
careful ordering of the replacements or by
an intermediate replacement value. The later
looks like it works for you:

    s = "stuff *wikilink* and\\*asciiemhasised\\*stuff"
    -- 'hide' the \* pattern
    s = string.gsub(s, "%\\%*", "&escapedstar;")
    s = string.gsub(s, "%*(%w+)%*",
         "<a http://so.m.e/luaspace/%1>%1</a>")
    -- Put "\*" back as just plain "*"
    s = string.gsub(s, "%&escapedstar%;", "*")
-- printed result is: 
-- stuff <a http://so.m.e/luaspace/wikilink>wikilink</a> and

Hope this helps,
   - Tom Wrensch

>>> 12/12/02 02:40 AM >>>

Hm, after trying all versions I think which could be right, I have to 
admit, that gsub patterns seems to high for me (uhoh). For example, I 
have "*wikilink*" and "\*asciiemphasized\*" in a string. I want to 
convert the first to "<a 
href="http://so.m.e/luaspace/wikilink";>wikilink</a>" and the second to 
"*asciiemphasized*" in the output, how do I achieve that the simpliest

Regards, Markus