Jump to content

User:Joeytje50/RETF

From Wikipedia, the free encyclopedia

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 some older browsers do not support lookbehinds in Regular Expressions, any replacement rules containing lookbehinds (?<= and ?<!) will be ignored for those who don't. As of 2023, all modern browsers should fully support this feature, however.

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

[edit]
  • User:Joeytje50/JWB#Typo fixing for an applied example of this script. This also documents some of the specific matching rules that are applied to RETF.