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%;", "*")
    print(s)
    
-- printed result is: 
-- stuff <a http://so.m.e/luaspace/wikilink>wikilink</a> and
*asciiemhasised*stuff

Hope this helps,
   - Tom Wrensch

>>> Fritsche.Markus@gmx.net 12/12/02 02:40 AM >>>
Hi!

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
way?

Regards, Markus

-- 
http://reauktion.de/archer/