Difference between revisions of "FormatCommas"

From Sega Retro

 
Line 1: Line 1:
<includeonly>{{#vardefine:i|0}}{{#vardefine:input|{{#replace:{{{1|}}}|<nowiki> </nowiki>|_}}}}
+
<includeonly>{{#vardefine:ci|0}}{{#vardefine:input|{{#replace:{{{1|}}}|<nowiki> </nowiki>|_}}}}
 
{{#while:
 
{{#while:
| {{#if:{{#sub:{{{1|}}}|{{#var:i}}}}|true}}
+
| {{#if:{{#sub:{{{1|}}}|{{#var:ci}}}}|true}}
| {{#vardefine:currentchar|{{#sub:{{#var:input}}|{{#var:i}}|1}}}}{{#switch:{{#var:currentchar}}
+
| {{#vardefine:currentchar|{{#sub:{{#var:input}}|{{#var:ci}}|1}}}}{{#switch:{{#var:currentchar}}
 
|[={{#vardefine:link|true}}
 
|[={{#vardefine:link|true}}
 
|]={{#vardefine:link}}
 
|]={{#vardefine:link}}
Line 8: Line 8:
 
|,={{#if:{{#var:link}}|{{#vardefine:return|{{#var:return}},,}}|{{#vardefine:return|{{#var:return}}{{#var:currentchar}}}}}}
 
|,={{#if:{{#var:link}}|{{#vardefine:return|{{#var:return}},,}}|{{#vardefine:return|{{#var:return}}{{#var:currentchar}}}}}}
 
|#default={{#vardefine:return|{{#var:return}}{{#var:currentchar}}}}
 
|#default={{#vardefine:return|{{#var:return}}{{#var:currentchar}}}}
}}{{incvar|i}}
+
}}{{incvar|ci}}
}}{{#replace:{{#replace:{{#var:return}}|_|<nowiki/> <nowiki/>}}|,,|_}}{{clearvar|i|input|return|currentchar}}</includeonly><noinclude>When storing names, [[Template:Company]] splits by commas. But some companies have commas in their names.
+
}}{{#replace:{{#replace:{{#var:return}}|_|<nowiki/> <nowiki/>}}|,,|_}}{{clearvar|ci|input|return|currentchar}}</includeonly><noinclude>When storing names, [[Template:Company]] splits by commas. But some companies have commas in their names.
  
 
This template turns those commas into a placeholder character (_) to be swapped later.
 
This template turns those commas into a placeholder character (_) to be swapped later.

Latest revision as of 09:42, 13 September 2024

When storing names, Template:Company splits by commas. But some companies have commas in their names.

This template turns those commas into a placeholder character (_) to be swapped later.

{{FormatCommas|[[Club Specialty Overseas, Inc.]], [[Sega Inc.]]}}

Club Specialty Overseas_ Inc., Sega Inc.