Module:Excerpt: Difference between revisions

Content deleted Content added
Use match instead of find, to capture the current string position with ()
Remove stray }} etc. at end of text
Line 560:
until text == t
 
text = text.gsub(text, "([{}%[%]])%1[^\27].*", ""); -- remove unmatched {{, }}, [[ or ]] and everything thereafter, avoiding ]E]]E] etc.
text = text.gsub(text, "([{}%[%]])%1$", ""); -- remove unmatched {{, }}, [[ or ]] at end of text
text = mw.ustring.gsub(text, "\27", ""); -- unhide matched pairs: E{E{ → {{, ]E]E → ]], etc.