User:Ohconfucius/script/Sources.js: Difference between revisions

Content deleted Content added
allign to test script (ref names function)
align to test script
Line 25:
var txt=document.editform.wpTextbox1;
//test
regex(/\s?(<ref>(?:[^<>]*\|\s*url\s*=|\[?)https?:\/\/((?:\w+\.)*\w+(?:\.(?:com?|org|net|gov|ac|)(?:\.[a-z]{2}|)))\/[^<>{}]+\|publisher=)(?=}}<\/ref>)/gi, "$1$2"); //capture ___domain name to add to publisher
regex(/(\|\s?(?:publisher|website)\s*\=\s*)w{3}\.(\w+\.(?:com?|org|net|gov|ac|)(?:\.[a-z]{2}|))(?=\s*[|}])/gi, '$1$2');
regex(/(\|\s?publisher=)\s?\|\s?via\s*\=\s*(\w+)(?=\s*[|}])/gi, '$1$2');
// regex(/\|\s?via\s*\=\s*/gi, '|work=');
regex(/\s?[-–]\s?(?:The |)(\w+\.(?:com?|org|net|gov|ac|)(?:\.[a-z]{2}|))\s?(\|\s?publisher\s*\=\s*)\1(?=}})/gi, '$2$1');
regex(/\s?[-–]\s?([^|]+)\s?(\|\s?publisher\s*\=\s*)(The )\1(?=}})/gi, '$2$3$1');
regex(/\|\s?first\s*\=[^|]*\|\s?last\s*\=(?:Editor|Group|Staff|Reporter|Writer)\s*(?=\|)/gi, '');
Line 42:
// removing http links within publisher/journal/work fields
//
regex(/((?:author|publisher|work) *= *)(?:https?:|ftp:)\/{2}(?:\w{2,4}\.|)(\w+)\.(?:com?|net|org|gov)(?:\.\w{2}|)(?:\/[^|}]*|)(?=\s*[\]|}])/gi, '$1$2');
regex(/(\|\s?(?:author(?:link\d?|)|chapter|journal|magazine|newspaper|publisher|title|work|via)\s*\=\s*)(?:https?:\/\/|)www\.(\w)\/?/gi, '$1$2'); //leave only ___domain name
regex(/(>{{cit[^}]+\|\s?(?:via|website)\s*\=\s*)(?:https?:\/\/|)www\.(\w[^}<]+)(?=}}<)/gi, '$1$2'); //leave only ___domain name
regex(/(\|\s?(?:newspaper|workchapter|journal|magazine|newspaper|publisher|title|work|via)\s*\=\s*)\[?https?:\/\/[^\s\]]*\s([\w][^\]]*)\]?/gi, '$1$2'); //leave only linked text
 
regex(/(\|\s?author(?:link\d?|)\s*\=\s*)\[https?:\/\/[^\s\]]*\s([\w][^\]]*)\]/gi, '$1$2');
regex(/(\|\s?author(?:link\d?|)\s*\=\s*)(?:https?:\/\/|)www\.[\w][^|}]*(?=[|}\n])/gi, '$1'); //rem outright (not a WL)
 
// removing references to other WP articles and 'external' WP links
Line 61 ⟶ 62:
regex(/(<ref>\s*https?:\/\/(?:(?:www\.|)(?:facebook|myspace|twitter|mailonline|findagrave)\.com|dailymail\.co\.uk)\/[^\s\]<]*)(<\/ref>)/gi, '$1{{Primary source inline}}$2');
regex(/(<ref>\s*\[https?:\/\/(?:(?:www\.|)(?:facebook|myspace|twitter|mailonline|findagrave)\.com|dailymail\.co\.uk)\/[^\s\]]*[ ]+[\w\d][^\]]*\])(<\/ref>)/gi, '$1{{Primary source inline}}$2');
 
//deprecated sources
regex(/<ref[^<>]*>[^<>]*\|[ ]*url ?=https?:\/\/(?:(?:\w+\.|)(epochtimes|ntdtv)\.com)\/[^<>{]*<\/ref>/gi, '<!--rem deprecated source \($1\)-->');
regex(/<ref[^<>]*>[^<>]*\|[ ]*url ?=https?:\/\/(?:(?:\w+\.|)(thesun|dailymail)\.co\.uk)\/[^<>{]*<\/ref>/gi, '<!--rem deprecated source \($1\)-->');
 
regex(/(\|\s?url\s*\=\s*|\[)(https?:[^|{}#\s]+)#[A-Za-z0-9\.]{12,13}(?=[\s\[\]|{}<>])/gi, '$1$2'); //rem link tracking
Line 85 ⟶ 90:
regex(/(\|\s?pages?\s*\=\s*)(?:pages?|p[gp]?\.?)[ ]*(\d)/gi, '$1$2');
regex(/ [-–] (?:每日明報 daily news|東方日報)/gi, '');
regex(/ (\.\.\. |)\{\{!\}\} 立場(報道|新聞)/gi, '');
regex(/(\|\s?title\s*\=\s*)Login ?(?=[|}])/gi, '$1ACTUAL1'); ARTICLE//creating TITLEdeliberate BELONGSerror HERE'(blank title); per Trappist
regex(/(\|\s?)(?:publisher|website|work)=You ?tube(?:\.com|)(?=\s*[|}])/gi, '$1via=YouTube');
regex(/(\|\s?)(?:publisher|website|work)=(Amazon)(?:\.com|)(?:\.\w{2}|)(?=\s*[|}])/gi, '$1via=$2');
regex(/(\|\s?)(?:publisher|website|work)=(Vimeo)(?:\.com|)(?=\s*[|}])/gi, '$1via=$2');
regex(/(\|\s?)(?:publisher|website|work)=(Newspapers\.com)(?=\s*[|}])/gi, '$1via=$2');
regex(/(\|\s?publisher=)\|\s?via\s*\=\s*(\w+)(?=\s*[|}])/gi, '$1$2');
regex(/(?:-[ ]*Google Books[ ]*(?:\|[^}]*|)|)\|\s?publisher\s*\=\s*(Google Books)(?=[\s\.]*[|}])/g, '|via=$1');
Line 112 ⟶ 118:
regex(/(\|\s?publisher\s*\=\s*)(?:\[\[copyright(?:\|©|)\]\])\s?/gi, '$1');
regex(/(\|\s?publisher\s*\=\s*)(?:©|copyright)\s?/gi, '$1');
regex(/(\|\s?title\s*\=\s*[^|}]+?)[-‒–—―] *\s+([^|}]+?)(\|\s?(?:publisher|work)\s*\=\s*\2)/gi, '$1$3');
regex(/(\|\s?title\s*\=\s*([^|}]+?))[-‒–—―] *\s+([^|}]+?\|\s?(?:publisher|work)\s*\=\s*\2)/gi, '$1$3');
// misused 'date' parameter
Line 153 ⟶ 159:
 
// adjust for possibly incorrectly input title
// regex(/(\|\s?title\s*\=\s*)([^\|\}<>]*)(\s?\|[^}<>]*|)\|\s?(publisher|work)\s*\=\s*(?:\1|\[\[\1\]\])(?=\s*[|}])/g, '$1ACTUAL ARTICLE TITLE BELONGS HERE!1 |$4=$2$3'); //creating deliberate error (blank title) per Trappist
// regex(/(\|\s?title\s*\=\s*)(\w+\.com)(?=\s?[=|{}])/gi, '$1ACTUAL1<!--ACTUAL ARTICLE TITLE BELONGS HERE!--> |publisher=$2');
// rem misplaced punctuation
Line 161 ⟶ 167:
 
// removing blank or redundant parameters
regex(/(?:\|[ ]*(?:access-?date|agency|archive-?(?:date|url)|arxiv|asin|at|author(-?link|-mask|-name-separator|-separator|\d|\d-link|link\d?|)|bibcode|chapter|chapter-url|coauthors?|contribution(?:-url|)|date|deadurl|display-authors|doi|doi-inactive|doibroken|edition|(?:editor|translator)(?:-first|-last|-link|\d|\d-first|\d-last|\d-link)|(?:first|last)\d?|format|id|is[bs]n|issue|jfm|journal|jstor|language|lay(?:date|source|summary)|lccn|___location|magazine|day|month|mr|newspaper|nopp|oclc|ol|origyear|osti|others|pages?|periodical|place|pm[cd]|pmid|postscript|publication(?:-date|-place)|publisher|quote|ref|rfc|separator|series|ssrn|trans_title|type|url|volume|via|work|year|zbl)[ ]*=[\s]*)(?=[}|])/gi, '');
regex(/(?:\|[ ]*(began|ended)[ ]*=[^}|]*)(?=[}|])/gi, '');
regex(/(\|\s?work\s?\=\s?)\[\[iTunes\]\] Archive\s/gi, '|publisher=[[iTunes Store]]');
Line 213 ⟶ 219:
regex(/(\[\[)Daily Star \((?:British|UK)\)(?=\|)/gi, '$1Daily Star (United Kingdom)');
regex(/(\[\[Metro)(?: \(Associated Metro Limited\)| \(Associated Newspapers\)| \(London newspaper\)| \(free London newspaper\)| UK| newspaper London| newspaper UK)(?=\|)/gi, '$1 (British newspaper)');
regex(/(\[\[)(?:Calcutta Telegraph|The Telegraph \((?:kolkatt?aCalcutta|India)\)|(?:The |)Telegraph India|Telegraphindia\.com)(?=\|)/gi, '$1The Telegraph (CalcuttaKolkata)');
regex(/(\[\[)Dawn(?:, Karachi| newspaper|\.com| \((?:Newspaper|Pakistan)\))(?=\|)/gi, '$1Dawn (newspaper)');
regex(/(\[\[The Pioneer)(?:, Karachi| newspaper| \((?:indian newspaper)\))(?=\|)/gi, '$1 (Indian newspaper)');
Line 244 ⟶ 250:
regex(/(?:\|\s?(newspaper|work|publisher)\s*\=\s*(ACP Magazines|The Herald and Weekly Times|John Fairfax (and Sons Ltd\.?|Holdings)|Fairfax(?: Media(?: Limited|)| Digital| newspapers|)))(?=[\s\.]*[|}])/gi, '');
regex(/(?:\|\s?(newspaper|work|publisher)\s*\=\s*\[\[(ACP Magazines|The Herald and Weekly Times|John Fairfax (and Sons Ltd\.?|Holdings)|Fairfax(?: Media(?: Limited|)| Digital| newspapers))\]\])(?=[\s\.]*[|}])/gi, '');
regex(/(?:\|\s?publisher\s*\=\s*(Alexander Lebedev|American Media|Associated Newspapers|Bauer (?:Consumer Media|Media Group)|Cond[eé] Nast(?: Publications|)|Daily Mail and General Trust|Devin Laz[ae]rine|Dow Jones & Company|Future plc|(Guardian|Telegraph) Media Group|(?:Guardian|Independent) News (?:and|&) Media (?:Limited|Ltd\.|)|Hachette Filipacchi Médias|Hearst (?:Corporation|Magazines(?: UK|))|Herald Media|IGN Entertainment|Imdb Inc\.?|InterMedia Partners|IDG|IPC Media|Lee Enterprises|Media ?News Group|Mortimer Zuckerman|MTV Networks|News (?:Corporation|International|Limited)|Prometheus Global Media|Reed Business Information|Rovi Corporation|Trinity Mirror|Times Newspapers|Nielsen (?: Media Research|Business Media)|Viacom|Time(?: Warner ?|)))(,? Inc| LL[CP]| Ltd|Limited|)[\s\.]*(?=[|}\n])/gi, '');
regex(/\|\s?publisher\s*\=\s*(?:The |)(?:Deseret News Publishing|Dispatch Printing|E\. W\. Scripps|Evening Post Publishing|Forbes(?: Publishing|, Inc\.)|Gannett?|Independent News & Media|Irish Times Trust|(?:Jann Wenner|Wenner Media)|Johnson Publishing|Journal Communications|Mac Publishing|Media24|McClatchy|Nash holdings LLC|New York Times|Seattle Times|Star Tribune|Thomp?son(?:[- ]?Reuters)?(?: Corporation| Plc.?|)|Torstar|Time Inc\.|Times (?:Group|Publishing)|Tribune|Vox Media|Washington Post|World Publishing|Ziff Davis Media)(?: Co(?:mpany|\.)?)?(?=[\s\.]*[|}])/g, '');
regex(/\|\s?publisher\s*\=\s*(?:Cox|Halifax|North Jersey|Sun-Times|Tampa|Herald|Stephens|WEHCO|\w+) Media(?: Group(?:,? Inc\.)?| Berhad)?(?=[\s\.]*[|}])/g, '');
// regex(/\|\s?publisher\s*\=\s*(?:\w+ )+(?:Media|Publishing|Publications)(?: Group(?:,? Inc\.)?| Berhad)(?=[\s\.]*[|}])/g, ''); //rem "Communications" - false positive for "Ministry of Economic Affairs and Communications" reported 28 May 2014
//duplicate above with links //("Corporation" excluded - false positive with Australian Broadcasting Corporation)
regex(/(?:\|\s?publisher\s*\=\s*\[\[(Alexander Lebedev|American Media|Associated Newspapers|Bauer (?:Consumer Media|Media Group)|Cond[eé] Nast(?: Publications|)|Daily Mail and General Trust|Devin Laz[ae]rine|Dow Jones & Company|Future plc|(Guardian|Telegraph) Media Group|(?:Guardian|Independent) News (?:and|&) Media (?:Limited|Ltd\.|)|Hachette Filipacchi Médias|Hearst (?:Corporation|Magazines(?: UK|))|Herald Media|IGN Entertainment|Imdb Inc\.?|InterMedia Partners|IDG|IPC Media|Lee Enterprises|Media ?News Group|Mortimer Zuckerman|MTV Networks|News (?:Corporation|International|Limited)|Prometheus Global Media|Reed Business Information|Rovi Corporation|Trinity Mirror|Times Newspapers|Nielsen (?: Media Research|Business Media)|Viacom|Time(?: Warner ?|)))(,? Inc| LL[CP]| Ltd|Limited|)(?:\|[^\]\}]*|)\]\][\s\.]*(?=[|}\n])/gi, '');
regex(/\|\s?publisher\s*\=\s*\[\[(?:The |)(?:Deseret News Publishing|Dispatch Printing|E\. W\. Scripps|Evening Post Publishing|Forbes(?: Publishing|, Inc\.)|Gannett?|Independent News & Media|Irish Times Trust|(?:Jann Wenner|Wenner Media)|Johnson Publishing|Journal Communications|Mac Publishing|McClatchy|Nash holdings LLC|New York Times|Seattle Times|Star Tribune|Thomp?son(?:[- ]?Reuters)?(?: Corporation| Plc.?|)|Torstar|Time Inc\.|Times Publishing|Tribune|Vox Media|Washington Post|World Publishing|Ziff Davis Media)(?: Co(?:mpany|\.)?)?\]\](?=[\s\.]*[|}])/g, '');
regex(/\|\s?publisher\s*\=\s*\[\[(?:Cox|Halifax|North Jersey|Sun-Times|Tampa|Herald|Stephens|WEHCO|\w+) Media(?: Group(?:,? Inc\.)?| Berhad)?\]\](?=[\s\.]*[|}])/g, '');
// regex(/\|\s?publisher\s*\=\s*\[\[(?:\w+ )+(?:Media|Publishing|Publications)(?: Group(?:,? Inc\.)?| Berhad)\]\](?=[\s\.]*[|}])/g, '');
Line 334 ⟶ 340:
regex(/(''Panorama) \((Gibraltar)\)('')/g, '$1$3 ($2)');
regex(/(\|)(Panorama)(?: \(Gibraltar\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*Público) \((Portugal)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''Público) \((Portugal)\)('')/g, '$1$3 ($2)');
regex(/(\|)(Público)(?: \(Portugal\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*Público) \((Spain)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''Público) \((Spain)\)('')/g, '$1$3 ($2)');
regex(/(\|)(Público)(?: \(Spain\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The Pioneer) \((Indian newspaper)\)(\s*[|}])/g, '$1|___location=India$3');
regex(/(''The Pioneer) \((Indian newspaper)\)('')/g, '$1$3 (India)');
Line 371 ⟶ 383:
regex(/(''(?:Il Giorno)) \((newspaper)\)('')/g, '$1$3 (Italy)');
regex(/(\|)(Il Giorno)(?: \(newspaper\))(\]\])/g, '$1$2$3');
regex(/(= ?(?:El Universal)) \((Caracas|Cartagena|Mexico City)\)(?=[ ]*[|}])/g, '$1|___location=$2');
regex(/(''(?:El Universal)) \((Caracas|Cartagena|Mexico City)\)(?='')/g, '$1 \($2\)');
regex(/(\|El Universal)(?: \(Caracas|Cartagena|Mexico City\))(\]\])/g, '$1$2');
regex(/(= ?(?:RT)) \((TV network)\)([ ]*[|}])/g, '$1|___location=Russia$3');
regex(/(\|)(RT)(?: \(TV network\))(\]\])/g, '$1$2$3');
 
// regex(/(=[ ]*\[\[)([^\[\]\(\)\|:]*)( \([^\[\]\(\)\|]*\))(\]\])/gi, '$1$2$3|$2$4'); //adding piping to parentheticals inside parameters //disabled 7/3/2020 false positives (e.g. [[Communist Party of India (Marxist)]])
 
regex(/(?:author|agency|publisher)(\s*\=\s*\[\[[^()|]+ \((?:newspaper|magazine)\)\|[^\[\]|]+\]\])/gi, 'work$1');
Line 385 ⟶ 400:
regex(/(\w''\.)indiatimes\.com/gi, '$1');
 
regex(/\|[ ]?language[ ]?\=[ ]?English[ ]*?(?=[|}\n])/gi, ''); //note: adjusted for false positive in infoboxes books
regex(/- [\w]*\.com[ ]*\|/gi, '|');
regex(/(.) – Google [^ \]]*(\][\.,;]) Books\.google\.\w{2,3}(\.| )/gi, '$1$2Google Books$3');
Line 406 ⟶ 421:
 
// toggling domains within |website= parameter
// regex(/(\|\s?(?:work|website)\s*\=\s*)(\w+\.(?:com?|org|net|gov|ac|)(?:\.[a-z]{2}|))(?=\s*[|}])/gi, '$1\'\'$2\'\'');
 
 
// reordering 'work' and 'publisher'; reordering 'work' and 'website'
Line 422 ⟶ 436:
regex(/\|\s?publisher\s*\=\s*(\[\[(?:[^<|\]]*)\|([^}<>]*)\]\])(\|[^}<>]*|)\|\s?publisher\s*\=\s*(\1|\2)\.?(?=\s*[|}])/g, '|publisher=$1$3'); //piped work
 
regex(/(\|\s?(?:newspaper|website|work)\s*\=\s*(?:[^=|}\[<>]*)(?:\|[^}<>]*|))\|\s?websitework\s*\=\s*(?:[^|}]*)(?=\s*[|}])/g, '$1'); //unlinked work
regex(/(\|\s?(?:newspaper|website|work)\s*\=\s*\[\[([^<|\]]*)\]\](?:\|[^}<>]*|))\|\s?websitework\s*\=\s*(?:[^|}]*)(?=\s*[|}])/g, '$1'); //linked unpiped work
regex(/(\|\s?(?:newspaper|website|work)\s*\=\s*(\[\[(?:[^<|\]]*)\|([^}<>]*)\]\])(?:\|[^}<>]*|))\|\s?websitework\s*\=\s*(?:[^|}]*)(?=\s*[|}])/g, '$1'); //piped work
 
regex(/\|\s?___location\s*\=\s*New York(?: City|)\s*(\|[^}<>]*|)\|\s?___location\s*\=\s*(New York(?: City|)|USA)(?=[\s\.]*[|}])/g, '|___location=New York $1');
 
regex(/(?:\|[ ]*?___location=[^\|]*)(\|[ ]*?___location=[^|}]*)(?=[|}\n])+/gi, '$1');
regex(/(\|[ ]*?publisher=[^=}]*)(?:\|[ ]*?publisher=[^=}]*)(?=[|}\n])+/gi, '$1');
regex(/(\|[ ]*?work=[^=}]*)(?:\|[ ]*?work=[^=}]*)(?=[|}\n])+/gi, '$1');
 
//remove redundant parameter ('website' is an alias of 'work')
regex(/\|\s?(?:newspaper|website|work)\s*\=\s*([^=|}\[<>]*)(\|[^}<>]*|)\|\s?(?:newspaper|website|work)\s*\=\s*(?:\[\[[^\]]+\]\]|[|}]+)(?=\s*[|}])/g, '|work=$1$2'); //unlinked work
regex(/\|\s?(?:newspaper|website|work)\s*\=\s*\[\[([^<|\]]*)\]\](\|[^}<>]*|)\|\s?(?:newspaper|website|work)\s*\=\s*(?:\[\[[^\]]+\]\]|[|}]+)(?=\s*[|}])/g, '|work=$1$2'); //unpiped work
regex(/\|\s?(?:newspaper|website|work)\s*\=\s*(\[\[(?:[^<|\]]*)\|([^}<>]*)\]\])(\|[^}<>]*|)\|\s?(?:newspaper|website|work)\s*\=\s*(\1|\2)\.?(?=\s*[|}])/g, '|work=$1$3'); //piped work
 
//remove duplicated parameter created by conversions ('agency')
//'work' and its alias (post)
regex(/(\|[ ]*\s?(?:newspaper|work)[ ]agency\s*\=\s*([^\=|}\[<>]*)(?:\|[^\{\}<>]*|))(?:\|[ ]*\s?website[ ]agency\s*\=\s*(?:[^\]]+|[|}]*+)(?=\s*[|}\n])+/gig, '|agency=$1$2'); //unlinked agency
regex(/\|\s?agency\s*\=\s*\[\[([^<|\]]*)\]\](\|[^}<>]*|)\|\s?agency\s*\=\s*(?:\[\[[^\]]+\]\]|[|}]+)(?=\s*[|}])/g, '|agency=$1$2'); //unpiped agency
regex(/\|\s?agency\s*\=\s*(\[\[(?:[^<|\]]*)\|([^}<>]*)\]\])(\|[^}<>]*|)\|\s?agency\s*\=\s*(\1|\2)\.?(?=\s*[|}])/g, '|agency=$1$3'); //piped agency
 
//unwinding of unnecessary pipes
Line 447 ⟶ 463:
regex(/(?:&#124; (?:Daily|English|(?:Mail |)Online|Music|News|Indian Express))(?=\s*\|)+/gi, '');
 
regex(/(?:(?:[ ]+&#124;[ ]+HighBeam Research[ ]+[-–][ ]+FREE trial[ ]+|)\|publisher=Highbeam.com)/gi, '|via=Highbeam');
regex(/( &#124; [\w, ]*?)(?=[ ]&#124)/gi, '');
regex(/( &#124; Comment is free)/gi, '');
regex(/\|\s?title\s*\=\s*BBC (?:News|Sport)\s?(?:[-–]|&#124; )\s?/gi, '|title=');
regex(/\|\s?title\s*\=\s*Asia Times Online\s?(?:[-–]|&#124; |:+)\s?/gi, '|title=');
regex(/(?:Entertainment|Football|(?:inter|)national|Latest|local|Music|UK|world|) News &#124;(?=[ ]?[&\|])/gi, '');
regex(/(?:[-–|]|&#124;)[ ]*(?:Entertainment|Football|(?:inter|)national|Latest|local|Music|UK|world|) News(?=[ ]?[&\|])/gi, '');
regex(/<!-- Bot generated title -->/gi, '');
regex(/(\|\s?title\s*\=\s*[^|}]+?)[-‒–—―] *\s+([^|}]+?)(\|\s?(?:publisher|work)\s*\=\s*\2)/gi, '$1$3');
regex(/(\|\s?title\s*\=\s*([^|}]+?))[-‒–—―] *\s+([^|}]+?\|\s?(?:publisher|work)\s*\=\s*\2)/gi, '$1$3');
 
regex(/(DOC|PDF)\) \./gi, '$1).');
Line 473 ⟶ 489:
regex(/((?:[Rr]eferences|[Nn]otes)[ ]?={2,4}[\n\r])[\r\n\s]*<div (?:style|class)=[^>]*>([\S\s]*)<\/div>/g, '$1$2');
regex(/<[Rr]eferences ?\/>/g, '{{reflist}}'); //default
// regex(/({{reflist)\|30em([^}]*}})/g, '$1$2');
// regex(/({{reflist)\|[23]\d(?:\dem|)(}})/g, '$1$2'); //default
 
// disambiguating duplicated ref names
regex(/(<ref name=[^/>"]*)><\/ref>/gi, '$1/>');
regex(/(<ref name=[^/>"]*)>([\s\S]*)\1>([\s\S]*)\1>/gi, '$1A>$2$1B>$3$1C');
// regex(/(<ref name=[^/>"]*)>([\s\S]*)\1>/gi, '$1A>$2$1B>');
// regex(/(<ref name="[^/>]*)">([\s\S]*)\1>/gi, '$1A>$2$1B">');
}