Template:Trim brackets
Jump to navigation
Jump to search
This template is used on many pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
This template uses Lua: |
This template trims leading and trailing square brackets and whitespace from a string. This is similar to {{delink}}, but it won't remove brackets from the middle of the string. The string should be passed as the first unnamed parameter or using |1=
if your string contains any =
signs. You may substitute this template - that is, if used as {{subst:trim brackets}}
, the resulting wikicode is "clean".
Usage
{{trim brackets|text}}
= text with any leading or trailing square brackets removed (as long as text doesn't contain any =
signs).
{{trim brackets|1=text}}
= text with any leading or trailing square brackets removed.
Example
- "
{{trim brackets|1= [[abc]] }}
" produces "abc".
- "
{{trim brackets|1= [[abc]], [[def]], and [[ghi]] }}
" produces "abc]], def, and [[ghi"
("{{delink|1= [[abc]], [[def]], and [[ghi]] }}
" produces "abc, def, and ghi").
- "
{{trim brackets|1= [[abc|xyz]] }}
" produces "abc|xyz".
Template data
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Trim brackets in articles based on its TemplateData.
TemplateData for Trim brackets
<templatedata> {
"description": "The template trims leading and trailing square brackets from a string.", "params": { "1": { "label": "String", "description": "The string to be trimmed", "type": "string", "required": true } }
} </templatedata>
See also
- {{delink}}, which does nearly the exact same thing, but also removes balanced pairs of square brackets that aren't leading and trailing and has additional options.
- {{trim}}
- {{Escape page link from within}}
- {{Linked}} – links if not already linked