Special property "Allows pattern"
Allows pattern | |
---|---|
Pattern to match a permissible value
| |
Further Information | |
Provided by: | extension "Semantic MediaWiki "Allows to store and query data annotated to pages |
Added: | 2.4.0 |
Removed: | still in use |
Alias: | has no alias |
Optional: | yes |
Visible: | yes |
Annotable: | yes |
Declarative: | yes |
Key: | _PVAP
|
Setting: | SMW_DV_PVAP
|
Focus: | property restriction |
In this wiki: | Property:Allows pattern |
Table of Contents | |
The Allows pattern property is a special property in Semantic MediaWiki with a built-in meaning: it provides the possibility to specify a regular expression pattern to match permissible values. It is similar in it functionality to special property "Allows value"Lists one permissible value for a property. It was introduced starting with Semantic MediaWiki 2.4.0Released on 9 July 2016 and compatible with MW 1.19.0 - 1.27.x..1 It is enabled by default. See the help page on configuration parameter $smwgDVFeatures
Sets the available features regarding property data values for details on configuring Semantic MediaWiki for special data value features including "Allows pattern" with the SMW_DV_PVAP
option.
Features and limitations[edit]
- This special property can only be assigned via a reference.
- This can only validly be assigned once to a property. If more than one assignment is made the last one assigned takes precedence.2
- The references together with their regular expressions available for this special property are provided on system message page "Smw allows pattern" as a list.
- Only users with user right "
smw-patternedit
" can edit system message page "Smw allows pattern". - The regular expression modifier
/e
is not permitted and removed from any expression.
Example[edit]
System message "Smw allows pattern" can contain something like:
ISBN-10|ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$
- Allows matching a ISBN-105.- "
ISBN-10
" is the reference to be added to a property page like e.g.[[Allows pattern::ISBN-10]]
"ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$
" after the pipe is the assigned regular expression.
- "
Whitelist|^(Foo|Foo bar|Bar)$
- Allows whitelisting certain terms.- "
Whitelist
" is the reference to be added to a property page like e.g.[[Allows pattern::Whitelist]]
. "^(Foo|Foo bar|Bar)$
" after the pipe is the assigned regular expression.
- "
See <sandbox.semantic-mediawiki.org> for further examples.
Error Handling[edit]
When [[Foo::Bar]]
is used to set a property to a value that is not allowed, the property will not be set, and a warning sign will be shown. When using {{#set: Foo=Bar }}
to set the property, the error will be silently ignored. To find all pages that use a value that is not allowed, special property "Has improper value for"Alerts in case the assigned value to a property is invalid can be used.
Note[edit]
The Regular Expression Library (RexExLib.com) is a great resource for finding patterns.
See also[edit]
- User manual on MediaWiki's configuration parameter
$wgNamespaceProtection
(MediaWiki.org) - Help page on configuration parameter
$smwgDVFeatures
Sets the available features regarding property data values - Help page on user rights
- Help page on special property "Allows value"Lists one permissible value for a property
- Help page on special property "Allows value list"Adds a reference to a list of permissible values for a property
- Help page on special property "Has improper value for"Alerts in case the assigned value to a property is invalid
References
- ^ Semantic MediaWiki: GitHub pull request gh:smw:1417
- ^ Semantic MediaWiki: GitHub pull request comment gh:smw:1417:240831598
- ^ Catastrophic Backtracking "...going in circles, and aborts the match attempt. Other regex engines ... will keep going forever ..."
- ^ Regular expression for Denial of Service
- ^ regexlib.com