Difference between revisions of "Help:Regular expressions"

From Nookipedia, the Animal Crossing wiki
m (SuperHamster moved page Nookipedia:Regular expressions to Help:Regular expressions: Moving to help namespace)
(Added an online visual regex tester)
Line 13: Line 13:
 
* [https://regex101.com/ regex101.com]
 
* [https://regex101.com/ regex101.com]
 
* [https://regexr.com/ regexr.com]
 
* [https://regexr.com/ regexr.com]
 +
* [https://extendsclass.com/regex-tester.html extendsclass.com]
  
 
== Examples ==
 
== Examples ==

Revision as of 08:49, October 29, 2020

A regular expression (regex) is a sequence of characters defining a search pattern. On the wiki, they are commonly used for finding and replacing text through Special:ReplaceText (staff only), AutoWikiBrowser, Pywikibot, or Scribunto/Lua modules.

Each tool/programming language uses its own ruleset for regular expressions:

If you need help with regular expressions, you may post on the talk page, or join the Nookipedia Discord and ask in the #wiki-tech channel.

Testing

There are several online tools to test our patterns. A small selection is listed below.

Examples

Below is a list of examples of regular expressions that may help you on the wiki. Feel free to expand this list.

  • Matching a multi-line Foreignname template and adding a new "See also" section after it (Python):
Find: {{Foreignname([\s\S]*?\n}})
Replace: {Foreignname\1\n\n==See also==