Actions

Template

Difference between revisions of "Stripref"

From Sega Retro

(Mediawiki update makes this simple)
 
Line 1: Line 1:
<includeonly>{{clearvar|striprefresult}}{{#vardefine:input|{{#replace:{{#explode:{{{1}}}|<span|0}}| |_SPACE_}}}}{{#loop: subchar
+
<includeonly>{{#replace:{{{1}}}|aaa|aaa}}</includeonly><noinclude>This template removes references from a string.
| 0
 
| {{#len:{{#var:input}}}}
 
| {{#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.
 
  
 
==Usage==
 
==Usage==
<pre>{{stripref|123{{ref|http://segaretro.org}}}}</pre>
+
<pre>{{stripref|123{{ref|http://sega.com}}}}</pre>
 
returns:
 
returns:
  
{{stripref|123{{ref|http://segaretro.org}}}}
+
{{stripref|123{{ref|http://sega.com}}}}
 
 
 
 
<pre>{{stripref|123 456{{ref|http://segaretro.org}}}}</pre>
 
returns:
 
 
 
{{stripref|123 456{{ref|http://segaretro.org}}}}
 
  
  
 
<pre>{{stripref|123{{magref|egm|1|1}}}}</pre>
 
<pre>{{stripref|123{{magref|egm|1|1}}}}</pre>
returns:
 
 
{{stripref|123{{magref|egm|1|1}}}}
 
 
 
<pre>{{stripref|123 456{{magref|egm|1|1}}}}</pre>
 
 
returns:
 
returns:
  
Line 35: Line 19:
  
 
{{stripref|123{{fileref|bums.pdf|page=3}}}}
 
{{stripref|123{{fileref|bums.pdf|page=3}}}}
 
 
<pre>{{stripref|123 456{{fileref|bums.pdf|page=3}}}}</pre>
 
 
returns:
 
 
{{stripref|123 456{{fileref|bums.pdf|page=3}}}}
 
  
  
Line 51: Line 28:
  
  
 
+
<pre>{{stripref|123{{intref|bums}}}}</pre>
<pre>{{stripref|123{{intref|bums}}</pre>
 
  
 
returns:
 
returns:
  
 
{{stripref|123{{intref|bums}}}}
 
{{stripref|123{{intref|bums}}}}
 
 
<pre>{{stripref|123 456{{intref|bums}}}}</pre>
 
 
returns:
 
 
{{stripref|123 456{{intref|bums}}}}
 
  
 
''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.
 
''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.
  
 
[[Category:Sega Retro templates]]</noinclude>
 
[[Category:Sega Retro templates]]</noinclude>

Latest revision as of 16:43, 11 November 2019

This template removes references from a string.

Usage

{{stripref|123{{ref|http://sega.com}}}}

returns:

123


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

returns:

123More...


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

returns:

123


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

returns:

123 456Media:GoldenAxe2 MD EU Box.jpg


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

returns:

123

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.