Wikidata:Property proposal/applies if regular expression matches

From Wikidata
Jump to navigation Jump to search

applies if regular expression matches id[edit]

Return to Wikidata:Property proposal/Authority control

   Under discussion
Descriptionthe statement is only true, if the id matches this regex
Data typeString
Domainproperty
Allowed valuesvalid regular expression with at least one capture group
Example 1
Fandom article ID (P6262)
formatter URL (P1630)https://$2.fandom.com/$1/wiki/$3
if regex([\w]+).([\w-]+):([^\s])
Example 2
Fandom article ID (P6262)
formatter URL (P1630)https://$1.fandom.com/wiki/$2
if regex([\w-]+):([^\s])
Example 3
Fandom article ID (P6262)
https://www.fandom.com/index.php?title=w:c:$1
if regexno value
object has role (P3831) → fallback
Example 4
Gamepedia article ID (P6623)
formatter URL (P1630)https://$1.gamepedia.com/$2
if regex([\w-]+):([^\s])
Example 5
Gamepedia article ID (P6623)
formatter URL (P1630)https://tools.wmflabs.org/wikidata-externalid-url/?p=6623&id=$1
if regexno value
object has role (P3831) → fallback

Motivation[edit]

Fandom article ID (P6262) and Gamepedia article ID (P6623) use a third party services to resolve ids to urls. but i think it could be done entirely on wikidata, if it was possible to pass multiple variables to the formatter URL (P1630). This is a proposal to do that.

We'd need a qualifier holding a regular expression.

  1. the regex will be used to determine which formatter url shall be used. therefore it must not match if the supplied id does not hold the required number of variables.
  2. the regex will also be used to extract the variables from the id to the formatter url.
  3. as a fallback an external resolver may be used if no regex matches the id. this fallback should be highlighted somehow. For this proposal I chose no value. formatter urls that match the regular expression must be preferred.

--Shisma (talk) 21:00, 16 February 2020 (UTC)

Discussion[edit]

Do you intend to engage the Wikidata developers so this can be supported in the UI, or how otherwise would you envision this to be actually used? ArthurPSmith (talk) 15:31, 18 February 2020 (UTC)
@Shisma: Also maybe relevant - see Phabricator Task T150939 ArthurPSmith (talk) 19:27, 20 February 2020 (UTC)