Template:Trim leading
Sarna News
- HEXTECH Review - Wave 3 Brings More Urban Options To Your Battlefield
- Your BattleTech News Round-Up For March, 2024
- Crashing 'Mechs With Jennifer Brozek, Author Of The Rogue Academy Trilogy
- Getting The Word Out With Rem Alternis, Catalyst Community & Marketing Director
- Bad 'Mechs - Yeoman
- Read more →
x
Contents
Usage[edit]
{{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[edit]
- New code should strongly consider {{#invoke:string|replace}} or {{#invoke:MultiReplace|main}}.
- For backward compatibility, both the input and pattern string are trimmed of surrounding whitespace before processing begins. This means you cannot remove three instances of "the " from "the the the thing"; instead you will remove one instance of "the".
Examples[edit]
{{Trim leading|duck duck duck goose |duck}}
→ duck duck goose
{{Trim leading|duckduckduckgoose |duck}}
→ goose
{{Trim leading|00000034 }}
→ 34
{{Trim leading|aaaaaa34|a }}
→ 34
{{Trim leading|U+0034|U+}}
→ 0034
{{Trim leading|anti-anti-neutrino |anti-}}
→ neutrino
See also[edit]