Template:Constraint:Format
Exceptions are possible as rare values may exist. Exceptions can be specified using exception to constraint (P2303).
List of violations of this constraint: Database reports/Constraint violations/Constraint:Format#Format
List of violations of this constraint: Database reports/Constraint violations/Constraint:Format#Format
This template is obsolete. Please use property constraint (P2302) with value format constraint instead. For further information, see Help:Property constraints portal. |
Template documentation[view · edit · history · ] [translate this template]
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.
Usage
edit{{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 space
editDo not include spaces!
- Good:
{{Constraint:Format|pattern=\d\d}}
- Bad:
{{Constraint:Format|pattern= \d\d }}
Special formats
editIf 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 values
edit- 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 also
editExternal tools
editThe above documentation is transcluded from Template:Constraint:Format/doc (edit | history). Editors can experiment in this template's sandbox (create | mirror) and testcases (create) page. Please add categories to the /doc subpage. Subpages of this template. |