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))
I would like to replace every \hyperref after , before end of \authors?
My replacement is required as:
\\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}{}}}}}}}
,\\hyperref[{cqgab7bbaaf3}]in your input string and you want to replace it, but what do you want to replace it by? – David Carlisle Nov 23 '20 at 10:01andbefore last affiliation (like 1,2 and 3) or (like 1,2,3 and 4) etc... – Balaji Nov 23 '20 at 10:06