Open main menu

Template:Constraint:Format

Format: value must be formatted using this pattern (PCRE syntax).
{{{pattern}}}
Exceptions are possible as rare values may exist.
List of this constraint violations: Database reports/Constraint violations/Constraint:Format#Format
Documentation icon Template documentation[view] [edit] [history] [purge][Translate ⧼Templates⧽]

If a string also includes leading or trailing whitespaces, non printable characters, %20 marks, etc, the report will list the string as incorrectly formatted.

Constraints are described using a form of regular expression.

This template categorizes talk pages into Category:Properties with format constraints.

UsageEdit

{{Constraint:Format|pattern=}}

Sample:

  • Two digits: {{Constraint:Format|pattern=\d\d}}
  • Two digits or more digits, the first one not being a zero {{Constraint:Format|pattern=[1-9]\d+}}

White spaceEdit

Do not include spaces!

  • Good: {{Constraint:Format|pattern=\d\d}}
  • Bad: {{Constraint:Format|pattern= \d\d }}

Special formatsEdit

If the pattern includes curly braces or pipe ("|"), it needs to be included in nowiki tags.

Samples:

  • {{Constraint:Format|pattern=<nowiki>\d{1,4}</nowiki>}}
  • {{Constraint:Format|pattern=<nowiki>(tt|nm|ch|co)\d\d\d\d\d\d\d</nowiki>}}

Common valuesEdit

only digits 
{{Constraint:Format|pattern=<nowiki>\d+</nowiki>}}
lowercase letters, digits or a hyphen (dash) 
{{Constraint:Format|pattern=<nowiki>[a-z0-9\-]+</nowiki>}}
no spaces; no slashes 
{{Constraint:Format|pattern=<nowiki>[^\s\/]+</nowiki>}}

See alsoEdit

External toolsEdit