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/doc
(section)
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!
== Limitations (serious ones) == {{See also|Module:StripToNumbers/testcases}} * '''When imput may contain a {{code|1=..=..}} character, use {{para|1|}} when calling the template.''' This never does any harm. ::So: when input is <code>a=70%</code> use <code><nowiki>{{#invoke:StripToNumbers|main|1=a=70%}}</nowiki></code> → ::{{#invoke:StripToNumbers|main|1=a=70%}} * '''Otherwise,''' The input cannot contain the <code>=</code> character unless it is escaped as <code><nowiki>{{=}}</nowiki></code> or <code>&equal;</code>. ** There may be other characters than <code>=</code> that must be escaped. * At present, the module only does three things: *# It finds the first contiguous number in the input string, which may be preceded by <code>-</code> (the keyboard hyphen-minus character, not the formal unicode minus <code>β</code>, and may contain a decimal; it throws away everything else. *# It checks that the result is a valid number (i.e. not something like <code>1.2.3</code> or <code>1-2-3</code>, nor null; this test may well be redundant code at this point, but better safe than sorry. *# It optionally divides the number by two (in a separate function). : Feel free to expand it to do more things (and to do what it does more robustly if you find a way to break it). Please report problems on the talk page and ping regular editors of the module. It is safest in most cases to expand by adding functions rather than adding features to the <code>main</code> function. * It will drop trailing zeros from the end of decimal. It may be useful to add a feature to stop that behavior, so that it won't mess with currency formatting (this cannot reliably be done by removing the "is it really a number?" test, since invocation of the halving function will operate on the string as, and convert it to, a number not a string, and thus result in the truncation of mathematically redundant zeroes. * It cannot handle <code>=</code>-style character entities that are numeric (nor their hex equivalents), for obvious reasons, only named ones like <code>&equal;nbsp;</code> This can be addressed in future upgrade, surely, but should be done in a separate function, as stripping such input down to the ASCII character numbers may well be the desired use in a particular instance.
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)