AARoads:AutoWikiBrowser/RETF
The RegExTypoFix script makes it easy to perform every typo fix rule listed on Project:AutoWikiBrowser/Typos for the wiki it's executed from. If the typos page doesn't exist on the wiki it's run from, it doesn't work though. It can be imported into any script using the following:
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/RETF.js&action=raw&ctype=text/javascript');
After the script has loaded, you can run the RegEx Typo Fixes on a string using the following:
RETF.replace("exmaple peice of mispelled text"); //returns "example piece of misspelled text"
Any piece of text can be entered into that function, and it will automatically fix all typos found in it. The typo rules will not be applied to image names, template names and parameters, quotes, and any text following a colon or asterisk, as well as skipping any rule that also matches a wikilink target on that page. Also note that, since not all browsers support lookbehinds in Regular Expressions, any replacement rules containing lookbehinds (?<=
and ?<!
) will be ignored for those who don't. At the time of writing, this means Firefox is unable to perform some of the typo fixes. It is therefore recommended to run this script using either Google Chrome or Opera.
To reload the typos list, simply run the following code:
RETF.load();
which will re-evaluate all rules on the typos page. This will remove the rules that were removed from the page too.
See also
- AARoads:AutoWikiBrowser/JWB#Typo fixing for an applied example of this script. This also documents some of the specific matching rules that are applied to RETF.