Difference between revisions of "Template:Val/delimitnum"
Jump to navigation
Jump to search
blackwiki>Cpiral |
blackwiki>Cpiral |
||
| Line 1: | Line 1: | ||
| − | <includeonly>{{#ifeq: <!-- | + | <includeonly><!-- |
| − | {{#invoke:String|find|{{{1}}}|.}}<!-- Output | + | -->{{#ifeq: <!-- compare "04" to 4, and if so, output 4-digits pure |
| − | -->{{#invoke:String|len <!-- Length of 4 with sign | + | What might be "04" is composed of three outputs: dot, len, and fmt --> |
| − | |{{#invoke:String|replace|{{{1}}}|[+ | + | {{#invoke:String|find|{{{1}}}|.}}<!-- Output the zero if no dot. |
| − | + | -->{{#invoke:String|len <!-- Length of 4 with sign and spaces filtered? --> | |
| + | |{{#invoke:String|replace|{{{1}}}|[-+ ]|plain=false}}}}<!-- | ||
| + | That replace just filtered out any and all spaces, + or - characters. | ||
| + | But it's gotta have the minus sign first in the [-charclass]. | ||
| + | Any fmt given? If so comparison to "4" will fail -->{{{fmt|}}} | ||
| 4 |{{#invoke:String|replace|{{{1}}}|-|−}}<!-- | | 4 |{{#invoke:String|replace|{{{1}}}|-|−}}<!-- | ||
| − | If fmt is nil, found . is 0, and len is 4, then 04=4, | + | If fmt is nil, found . is 0, and filtered len is 4, then 04=4, |
| − | and we just output the number, replacing any - with a minus sign | + | and we have just output the number, replacing any - with a minus sign |
Else: | Else: | ||