如何使用 lua 正则表达式查找包含特殊字符的任何值

如何使用 lua 正则表达式查找包含特殊字符的任何值
local tex = '\\authors{\\author[]{{Surname} {FirstName}\\textsuperscript{\\hyperref[{article-id-affiliationnumber1}]}{{\\textsuperscript{,{\\textcolor{blue}{article-id-affiliationnumber2}}}}}{{\\textsuperscript{,\\hyperref[{cqgab7bbaaf3}]{\\textcolor{blue}{article-id-affiliationnumber3}}}}}{{\\textsuperscript{,\\hyperref[{cqgab7bbaem1}]{\\textcolor{blue}{}}}}}}}'

local function commafix (text)
    local pattern = '%$}{%$'
    local count = 0
    for _ in tex:gmatch (pattern) do
        count = count + 1
    end
    return tex:gsub (pattern, ',$}\n{$', count - 1):gsub (pattern, '$}\n and \n{$')
end
    io.write(commafix (tex))

我想替换结束后的\hyperref每个之前?,\authors

我的替换者要求如下:

\\authors{\\author[]{{Surname} {FirstName}\\textsuperscript{\\hyperref[{article-id-affiliationnumber1}]}{{\\textsuperscript{,{\\textcolor{blue}{article-id-affiliationnumber2}}}}}{{\\textsuperscript{ and \\hyperref[{cqgab7bbaaf3}]{\\textcolor{blue}{article-id-affiliationnumber3}}}}}{{\\textsuperscript{,\\hyperref[{cqgab7bbaem1}]{\\textcolor{blue}{}}}}}}}

相关内容