From StrategyWiki, the video game walkthrough and strategy guide wiki
Jump to navigation Jump to search

Regular expressions, often referred to as a regex or regexp, plural regexes or regexps, are used to help find changes that need to be replaced and to replace them.

Tools[edit]

To use a regular expression you will have to have find a code base that can run it. The easiest tools to use are:

  • Google Chrome extension: Search and Replace 1.2.2
  • TextPad (go to Search >> Replace, or press F8). Note: TextPad used to use Unix's implementation and syntax, but now uses Perl/JavaScript's.

Syntax differences[edit]

Note that some tools code their regular expression syntax differently. Major differences occur between programming languages and shells; e.g. Unix vs. Perl/JavaScript implementations.

Example: a simple parameter definition search in Unix may look like (this matches all characters a-b and 0-9, minimum of 1 time and maximum of 25 times in a single match):

\(a-b,0-9)\{1,25\}\)

In Perl/Javascript syntax it looks like:

(a-b,0-9){1,25}

For example, TextPad makes uses of simplified expressions, such as [:alpha:] to match a-z and A-Z.

Example uses[edit]

  • Adding a hundred file names to a table. See this example.
    • Regex used (in old TextPad Unix syntax): "| || \([[:alpha:][:blank:]]\{10,20\}\) || \(.\{1,10\}\) Bells" (without quotes).
  • Simplifying all lines with five character or above Pokemon names, and their identification number, in {{PokePic}}.
    • Regex used (in new Textpad Perl/JavaScript syntax; without quotes): "\|([[:alpha:]]{5,25}) = [[][[]File[:]Pokemon ([0-9]{3})\{\{\{1\}\}\}.png\{\{!\}\}\{\{\{2\|40px\}\}\}\{\{!\}\}\{\{\{3\|none\}\}\}\]\]"