Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:StripToNumbers/testcases
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{test cases}} ==Strip units from CSS values (why I want this)== * Input: <code>-12em, 34px, 56.7%, "89", 0</code> * Result: {{#invoke:StripToNumbers | main | -12em, 34px, 56.7%, "89", 0 }} * Input (will choke because of multiple <code>.</code> characters: <code>-12em, 34px, 56.7%, "8.9", 0</code> * Result: {{#invoke:StripToNumbers | main | -12em, 34px, 56.7%, "8.9", 0 }} * Input (will choke because of multiple <code>-</code> characters: <code>-12em, 34px, 57%, "-8.9", 0</code> * Result: {{#invoke:StripToNumbers | main | -12em, 34px, 57%, "-8.9", 0 }} * Input: <code>inherit</code> * Result: {{#invoke:StripToNumbers | main | inherit }} ==Find numbers in a bunch of stuff== * Input: <code>SDks]df9s>dfjklasdfk9kasdfkasdkie0kmc'@(aks</code> * Result: {{#invoke:StripToNumbers | main | SDks]df9s>dfjklasdfk9kasdfkasdkie0kmc'@(aks}} * Input: <code>"12.3x4"</code> * Result: {{#invoke:StripToNumbers | main | "12.3x4" }} ==Halve number found in stuff== * Input: <code>foobarbaz50%blahblahblah</code> * Result: {{#invoke:StripToNumbers | halve | foobarbaz50%blahblahblah}} * Input: <code>-66.6666666666666666666666666666</code> * Result: {{#invoke:StripToNumbers | halve | -66.6666666666666666666666666666}} * Input: <code>chickenbutt</code> * Result: {{#invoke:StripToNumbers | halve | chickenbutt }} ==Nastier input tests== * Input: <code>style="font-size: 70% ;"</code> * Result: {{#invoke:StripToNumbers | main | style="font-size: 70% ;"}} * Input: <code>'style="font-size: 70% ;"'</code> * Result: {{#invoke:StripToNumbers | main | 'style="font-size: 70% ;"'}} * Input: <code>`style="font-size: 70% ;"`</code> * Result: {{#invoke:StripToNumbers | main | `style="font-size: 70% ;"`}} * Input: <code>=70%</code> * Result: {{#invoke:StripToNumbers | main | =70% }} Yeah, it dies on contact with <code>=</code>. Can it be escaped? (see below: use {{para|1|=70%}}) * Input: <code>{<nowiki />{=}}70%</code> * Result: {{#invoke:StripToNumbers | main | {{=}}70% }} * Input: <code>style{<nowiki />{=}}"font-size: 70% ;"</code> * Result: {{#invoke:StripToNumbers | main | style{{=}}"font-size: 70% ;"}} * Input: <code><span style{<nowiki />{=}}"font-size: 70%;"></code> * Result: {{#invoke:StripToNumbers | main | <span style{{=}}"font-size: 70%;">}} * Input: <code><span style<nowiki>=</nowiki>"font-size: 70%;"></code> * Result: {{#invoke:StripToNumbers | main | <span style<nowiki>=</nowiki>"font-size: 70%;">}} Yes, though only with {{tlx|{{=}}}}; it chokes on {{tag|nowiki}}. Though this points out the relative uselessness of trying to use this on strings this complicated, since <code>-70</code> is the opposite of the desired output, <code>70</code>. It needs to be able to discern with <code>-</code> is directly associated with a numeral (or perhaps a <code>.</code>, since while <code>-.7</code> is crappy style, it's still a technically valid way to write <code>-0.7</code>. '''Try''': {{para|1|=70%}} * Input: <code>1=70%</code> * Result: {{#invoke:StripToNumbers | main | 1=70% }} {{aye}} * Input: <code><span class="nowrap"><span data-sort-value="7001123000000000000β "></span>12.3</span></code> (produced by <nowiki>{{val|12.3}}</nowiki>) * Result: {{#invoke:StripToNumbers | main | 1=<span class="nowrap"><span data-sort-value="7001123000000000000β "></span>12.3</span>}} == After upgrade to match more narrowly == * Input: <code>style{<nowiki />{=}}"margin-left: 10% ;"</code> * Result: {{#invoke:StripToNumbers | main | style{{=}}"margin-left: 10% ;"}} * Input: <code>style{<nowiki />{=}}"margin-left: -10% ;"</code> * Result: {{#invoke:StripToNumbers | main | style{{=}}"margin-left: -10% ;"}} * Input: <code>Weasels - 12. Chickens - 72.</code> * Result: {{#invoke:StripToNumbers | main | Weasels - 12. Chickens - 72.}}
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Aye
(
edit
)
Template:Para
(
edit
)
Template:Tag
(
edit
)
Template:Test cases
(
edit
)
Template:Tlx
(
edit
)
Module:Arguments
(
edit
)
Module:StripToNumbers
(
edit
)
Module:Template link general
(
edit
)