Template:Title year range/doc

Extracts a year range from a page title.

Explanation
A "year range" is a four-digit number followed by an endash with no spaces, and then two or four digits: YYYY–YY or YYYY–YYYY.

Note that separator must be an endash: –

The template will not recognise other separators, such as
 * hyphen: -
 * emdash: &mdash;

Examples of valid year ranges

 * 1651–1652 ✅
 * 1427–1509 ✅
 * 1706–1707 ✅
 * 1706–07 ✅
 * 1924–29 ✅
 * 1806–2014 ✅

Examples of invalid year ranges

 * 1725-34 ❌ (not an endash)
 * 1966—67 ❌ (not an endash)
 * 601–08 ❌ (leading year is only 3 digits)
 * 45025–34 ❌ (five digits in leading year, will be read as 5025–34)

Usage


or

or



TemplateData
{	"params": { "1": {			"aliases": [ "match" ],			"label": "Match Instance", "description": "If multiple year ranges are found, this specifies which match to return, where the first match is match= 1. If a negative number is specified then a match is returned counting from the last match. Hence match = -1 is the same as requesting the last match. Defaults to 1.", "type": "number", "default": "1" },		"2": {			"aliases": [ "nomatch" ],			"label": "No match text", "description": "If no year range is found, output the \"nomatch\" value. Defaults to blank.", "type": "string" },		"page": { "label": "Override page title", "description": "Specified a page title to use other than the current page. If left blank, the template will use the title of the current page", "type": "wiki-page-name", "default": "" }	},	"description": "Extracts a year ranges from the current page title. All parameters are optional." }