Template:Constraint:Format/doc
![]() | This is a documentation subpage for Template:Constraint:Format. It contains usage information, categories, and other content that is not part of the original template page. |
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
edit