Help:Titleparts

From Meta, a Wikimedia project coordination wiki
Jump to: navigation, search

Parser function #titleparts produces a subsequence of a sequence of up to 25 strings separated by slashes (if there are more than 24 slashes the excess slashes are treated as plain text belonging to the 25th string). Since it was designed for application to a page title the total string has to be a valid page title, otherwise this total string is returned. This means that the total amount of memory including that for the slashes is limited to 255 bytes and that some characters including rectangular brackets are not allowed. Also, on retrieval some changes to the canonical form occur; e.g., the first character of the first string in the original sequence is usually capitalized, see below.

{{#titleparts: total string | m | n }} returns m strings starting from the nth.

For m = 0 (the default) all strings from the nth are returned. A negative value -m indicates that m strings should be removed from the right. The default of n is 1. For n = 0 the result is the same. A negative value -n indicates that the leftmost string in the result should be the nth string from the right.

  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j}}" → "A/b/c/d/e/f/g/h/i/j" [1]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|4}}" → "A/b/c/d" [2]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j||2}}" gives "b/c/d/e/f/g/h/i/j" [3]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|0|2}}" gives "b/c/d/e/f/g/h/i/j" [4]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|4|2}}" gives "b/c/d/e" [5]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|9|2}}" gives "b/c/d/e/f/g/h/i/j" [6]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|10|2}}" gives "b/c/d/e/f/g/h/i/j" [7]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|4|11}}" gives "" [8]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4}}" → "A/b/c/d/e/f" [9]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4|5}}" gives "e/f" [10]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4|6}}" gives "f" [11]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4|7}}" gives "" [12]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4|8}}" gives "" [13]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j||-4}}" gives "g/h/i/j" [14]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|3|-4}}" gives "g/h/i" [15]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|4|-4}}" gives "g/h/i/j" [16]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|5|-4}}" gives "g/h/i/j" [17]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-2|-4}}" gives "g/h" [18]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4|-2}}" gives "" [19]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z|1|1}}" gives "a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z" [20]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x|1|1}}" gives "A" [21]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x|1|25}}" gives "y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x" [22]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x|1|26}}" gives "" [23]
  • "{{#titleparts:éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/|1|1}}" gives "éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/" [24]

Special considerations[edit]

Slashes are not allowed in the strings, except in the 25th string and in strings starting with ./ (see below), since they are used as separator. Unlike the pipes the slashes need not be explicit in the wikitext, they can be produced by expansion. This also means that the slash cannot be part of a string even with a technique like {{!}}.

Some special results:

  • "{{#titleparts:a / c|1|1}}" gives "A " [25] (a becomes A, as already seen above; space is preserved)
  • "{{#titleparts:a / c|1|2}}" gives " c" [26] (space is preserved)
  • "{{#titleparts:talk:b/c|1|1}}" gives "Talk:B" [27] (t and b are capitalized
    • compare: "{{#titleparts:tlk:b/c|1|1}}" gives "Tlk:b" [28] (t is capitalized
  • "{{#titleparts:w:a/c|1|1}}" gives "w:a" [29] (neither t nor a is capitalized)
  • "{{#titleparts:a#b/c|1|1}}" gives "A" [30] (returns the substring before #)
  • "{{#titleparts::b/c|1|1}}" gives "B" [31] (leading colon is removed)
  • "{{#titleparts:a_b/c|1|1}}" gives "A b" [32] (underscore is converted to space)
  • "{{#titleparts:a  b}}" gives "A b" [33] multiple consecutive spaces are converted to a single one)
  • "{{#titleparts:a__b}}" gives "A b" [34] multiple consecutive underscores are converted to a single space)

Not a valid page name:

  • "{{#titleparts:./c|1|1}}" gives "./c" [35]
  • "{{#titleparts:./b/c|1|1}}" gives "./b/c" [36]
    • compare "{{#titleparts:a./b/c|1|1}}" gives "A." [37]

The changes in strings beyond the first are more limited:

  • "{{#titleparts:a/c_d|1|2}}" gives "c d" [38] (underscore is converted to space)
  • b c multiple consecutive spaces are converted to a single one)
  • b c multiple consecutive underscores are converted to a single space)

See also[edit]