User:Zhaofeng Li/RegexTools.js

// RegexTools v0.1 // 1) enable regex tools in Preferences>Gadgets>Advanced ("Add a sidebar menu of user-defined regex tools, with a dynamic form for instant one-use regex") // 2) add importScript('User:Zhaofeng Li/RegexTools.js'); to your common.js // 3) the tools should show up on the side menu "Scripts" // Always check the diff after using!

// Unbold headings: Removes '''s and s from headings regexTool('Unbold headings', 'regex_unboldHeadings'); function regex_unboldHeadings { regex(/(\=+)\(.+)\<\/big\>(\=+)/g, '$1$2$3'); // get rid of s   regex(/(\=+)\'{3}(.+)\'{3}(\=+)/g, '$1$2$3'); // get rid of '''s }

// Fix in-wiki external links: Changes stuff like "test" to "test" regexTool('Fix in-wiki external links', 'regex_inwikiExternalLinks'); function regex_inwikiExternalLinks { regex(/\[https{0,1}\:\/\/en\.wikipedia\.org\/wiki\/(\S+) (.+)\]/g, '$2'); regex_redundantCaptions; // also clean-up redundant captions }

// Fix redundant link captions: Changes stuff like "test" to "test" regexTool('Fix redundant link captions', 'regex_redundantCaptions'); function regex_redundantCaptions { regex(/\[\[([^\#\<\>\[\]\|\{\}]+)\|(\1)\]\]/g, '$1'); }