Definition from Wiktionary, the free dictionary
Jump to: navigation, search
Edit-copy green.svg Documentation for Module:utilities. [edit]
This page contains usage information, categories, interwiki links and other content describing the module.

This module is exports various general utility functions, which can be used by other modules.



Escapes the magic characters used in Regular Expression patterns. For example, "^$()%.[]*+-?|" becomes "%^%$%(%)%%%.%[%]%*%+%-%?%|".


format_categories(categories, lang, sort_key, sort_base, force_output)

Formats a list (table) of category names. The output is a string consisting of all categories with [[Category:...]] applied to each one, and the given sort key added. If the namespace is not the main, Appendix or Reconstruction namespaces, the output will be an empty string unless FORCE_OUTPUT is given. If no sort key is given:

  1. A default one is generated by using SORT_BASE (if given) or the current subpage name, and by removing hyphens from the beginning (so that suffixes can be sorted without a key).
  2. If a sort key is available for the given language, it is then used to create a sort key that follows the rules for that language.
  3. If the final sort key ends up being identical to PAGENAME (which is the default key used by the software), then it is omitted entirely, so that it can be used in combination with DEFAULTSORT.



This function is used by the {{categorize}}, {{catlangname}} and {{catlangcode}} templates.