Template:Trim leading/doc
{{#invoke:Message box|mbox}}
Usage
{{Trim leading | <input> | <prefix> }}
Trims up to six instances of <prefix> (such as: 0 or "anti-") from the beginning of <input>. <Prefix> is set to "0" by default (for removing leading zeroes from numbers). Template will not properly work beyond the first whitespace in the input.
Limitations
- Up to 100 chararacters in the input string. If possible, first check length of input string using {{Str len}}. Using strings longer than 100 characters may result in the error "max index is 100 for str_sub".
- Limited set of characters.
- Snags on whitespace.
- Expensive.
Examples
{{Trim leading |duck duck duck goose |duck}}
→ Expression error: Unexpected < operator.
{{Trim leading | duckduckduckgoose |duck}}
→ Expression error: Unexpected < operator.
{{Trim leading | 00000034 }}
→ Expression error: Unexpected < operator.
{{Trim leading | aaaaaa34| a }}
→ Expression error: Unexpected < operator.
{{Trim leading | U+0034|U+}}
→ Expression error: Unexpected < operator.
{{Trim leading |anti-anti-neutrino |anti-}}
→ Expression error: Unexpected < operator.
Technical
This template uses parser function {padleft}. It formerly called 6 subtemplates: Template:Trim leading/1, /2 ... /6, which are all functionally identical, allowing for up to six instantiations of prefix to be removed.
See also
{{#invoke:Navbox|navbox}}