Difference between revisions of "Stripref"

From Sega Retro

Line 2: Line 2:
 
| 0
 
| 0
 
| {{#len:{{#var:input}}}}
 
| {{#len:{{#var:input}}}}
| {{#if: {{#pos:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-1234567890,._/()'"|{{#sub:{{#var:input}}|{{#var:subchar}}|1}}}} | {{#vardefine:striprefresult|{{#var:striprefresult}}{{#sub:{{#var:input}}|{{#var:subchar}}|1}}}} }}
+
| {{#if: {{#pos:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-1234567890,._/()'"×|{{#sub:{{#var:input}}|{{#var:subchar}}|1}}}} | {{#vardefine:striprefresult|{{#var:striprefresult}}{{#sub:{{#var:input}}|{{#var:subchar}}|1}}}} }}
 
}}{{#replace:{{#var:striprefresult}}|_SPACE_|<nowiki> </nowiki>}}</includeonly><noinclude>This template removes references from a string.
 
}}{{#replace:{{#var:striprefresult}}|_SPACE_|<nowiki> </nowiki>}}</includeonly><noinclude>This template removes references from a string.
  

Revision as of 20:12, 12 February 2019

This template removes references from a string.

Usage

{{stripref|123{{ref|http://segaretro.org}}}}

returns:

123CategoryBadexternalreference


{{stripref|123 456{{ref|http://segaretro.org}}}}

returns:

123456CategoryBadexternalreference


{{stripref|123{{magref|egm|1|1}}}}

returns:

123


{{stripref|123 456{{magref|egm|1|1}}}}

returns:

123


{{stripref|123{{fileref|bums.pdf|page=3}}}}

returns:

123


{{stripref|123 456{{fileref|bums.pdf|page=3}}}}

returns:

123456


{{stripref|123 456{{fileref|GoldenAxe2 MD EU Box.jpg}}}}

returns:

123456


{{stripref|123{{intref|bums}}

returns:

123


{{stripref|123 456{{intref|bums}}}}

returns:

123456

Warning: Don't repeatedly use for the same string, because each usage is listed in the references section. Instead, store the string to a variable and use that.