# Modèle:Lead/SplitNumber

Jump to: navigation, search

The first parameter of the template: Lead may be given for instance as “12 (2)” and is therefor a combination of different things and needs to be split up into two parts:

1. the main lead number “12” → `{{Lead/SplitNumber|12 (2)|0}}` returns 12
2. and the go-back lead “(2)” → `{{Lead/SplitNumber|12 (2)|1}}` returns  (2) as a link.

Cases:

• Simple number: Return input + empty string
• Number plus number in parentheses, e.g. "12 (2)": Return 12 + (2), where 2 is formatted as a link (the backlink; this href of this must be without ()!)
• Number plus certain characters (used to distinguish multiple leads in a couplet, like "2, 2*, 2**"): Return 2 + *, etc.
• Number plus hyphen, like "2, 2-): Returns NOTHING + -, i.e. here the number is suppressed!
• Number plus certain letter (for couplets with MANY leads), like "2 a, 2 b, 2 c"): Return 2 + a, etc.
Note: in this case, a blank must be present between the number and the letter. "1b" will not work at present!

The subprocedure has three parameters: First parameter is the string to be split, second parameter 0 to return first, 1 to return second element. The third parameter "noformatting=1" suppresses actions like swap the 2nd and 1st part, (like "2-" returning "-" + ""). It currently works only in combination with the 2nd parameter set to "0" and enforces to always return the lead number.

## USAGE examples

123: actual = "123 + "; expected = "123 +"

123 (2): actual = "123 +  (2)"; expected = "123 + (2)" (where "(2)" is a link)

123*: actual = "123 + *"; expected = "123 + *"

123**: actual = "123 + **"; expected = "123 + **"

123***: actual = "123 + **"; expected = "123 + ***"

123-: actual = "– + "; expected = "– + (EMPTY)"

123': actual = "123 + ’"; expected = "123 + ’ "

123’’: actual = "123 + ’’"; expected = "123 + ’’ "

123 a: actual = "123 + a"; expected = "123 + a "

123a: actual = "123a + "; expected = "123a + (EMPTY)" -- It is known that this does not work without a blank!