Difference between revisions of "Fileext"

From Sega Retro

Line 1: Line 1:
<includeonly>{{#ifeq:{{#rpos:{{{1|}}}|.}}|-1||{{#sub:{{{1|}}}|{{#expr:{{#rpos:{{{1|}}}|.}}-{{#len:{{{1|}}}}}+1}}}}}}</includeonly><noinclude>
+
<includeonly>{{#if:{{#pos:{{{1|}}}|.}}|{{#explode:{{{1|}}}|.|-1}}}}</includeonly><noinclude>
 
This template returns the file extension of a file link or url.
 
This template returns the file extension of a file link or url.
  
==Example==
+
==Examples==
<tt><nowiki>{{fileext|Filename.txt}}</nowiki></tt>
+
{|class="prettytable"
 +
! Code || Result
 +
|-
 +
|
 +
<pre>{{fileext|Filename.txt}}</pre>
 +
| {{fileext|Filename.txt}}
 +
|-
 +
|
 +
<pre>{{fileext|https://segaretro.org/skins/foreground/assets/img/segaretro_logo.png}}</pre>
 +
| {{fileext|https://segaretro.org/skins/foreground/assets/img/segaretro_logo.png}}
 +
|-
 +
|
 +
<pre>{{fileext|Not a file name}}</pre>
 +
| {{fileext|Not a file name}}
 +
|-
 +
|
 +
<pre>{{fileext|String ending with a stop.}}</pre>
 +
| {{fileext|String ending with a stop.}}
 +
|}
  
gives the result:
+
[[Category:Sega Retro templates]]</noinclude>
 
 
{{fileext|Filename.txt}}
 
 
 
[[Category:Sega Retro templates|{{PAGENAME}}]]</noinclude>
 

Revision as of 11:13, 8 August 2018

This template returns the file extension of a file link or url.

Examples

Code Result
{{fileext|Filename.txt}}
txt
{{fileext|https://segaretro.org/skins/foreground/assets/img/segaretro_logo.png}}
png
{{fileext|Not a file name}}
{{fileext|String ending with a stop.}}