Anonymous
Not logged in
Talk
Contributions
Create account
Log in
Search
Editing
Module:String2/doc
(section)
From MEpedia, a crowd-sourced encyclopedia of ME and CFS science and history
Namespaces
Module
Discussion
More
More
Page actions
Read
Edit source
History
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!
== Functions == === upper === The upper function simply converts all characters to upper case. === lower === The upper function simply converts all characters to upper case. === title === The title function capitalises the first letter of each word in the text, apart from a number of short words recommended by ''The U.S. Government Printing Office Style Manual'': {{xt|a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and nor}}. === sentence === The sentence function finds the first letter and capitalises it, then renders the rest of the text in lower case. It works properly with text containing wiki-markup. Compare <code><nowiki>{{#invoke:String2|sentence|[[chronic fatigue syndrome]]}}</nowiki></code> -> {{#invoke:String2|sentence|[[chronic fatigue syndrome]]}} with <code><nowiki>{{ucfirst:{{lc:[[chronic fatigue syndrome]]}}}}</nowiki></code> -> {{ucfirst:{{lc:[[chronic fatigue syndrome]]}}}}. Piped wiki-links are handled as well: <code><nowiki>{{#invoke:String2|sentence|[[the sick and Tired (BBC)|sick and Tired]]}}</nowiki></code> -> {{#invoke:String2|sentence|[[sick and Tired (BBC)|sick and Tired]]}}. So are lists: * <code><nowiki>{{#invoke:String2 |sentence |{{hlist |canada |spain |france}}}}</nowiki></code> β {{#invoke:String2 |sentence |{{hlist |[[canada]] |[[spain]] |[[france]]}}}} === ucfirst === The ucfirst function is similar to sentence; it renders the first alphabetical character in upper case, but leaves the capitalisation of the rest of the text unaltered. This is useful if the text contains proper nouns, but it will not regularise sentences that are ALLCAPS, for example. It also works with text containing piped wiki-links and with html lists. === stripZeros === The stripZeros functions finds the first number in a string of text and strips leading zeros, but retains a zero which is followed by a decimal point. For example: "0940" -> "940"; "Year: 0023" -> "Year: 23"; "00.12" -> "0.12" === nowiki === The nowiki function ensures that a string of text is treated by the MediaWiki software as just a string, not code. It trims leading and trailing whitespace. === posnq === * posnq (position, no quotes) returns the numerical start position of the first occurrence of one piece of text ("match") inside another ("str"). * It returns nil if no match is found, or if either parameter is blank. * It takes the text to be searched in as the first unnamed parameter, which is trimmed. * It takes the text to match as the second unnamed parameter, which is trimmed and any double quotes " are stripped out. That allows spaces at the beginning or end of the match string to be included in a consistent manner.
Summary:
Please make sure your edits are consistent with
MEpedia's guidelines
.
By saving changes, you agree to the
Terms of use
, and you irrevocably agree to release your contribution under the
CC BY-SA 3.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
This page is a member of a hidden category:
Category:Pages with script errors
Navigation
Navigation
Skip to content
Main page
Browse
Become an editor
Random page
Popular pages
Abbreviations
Glossary
About MEpedia
Links for editors
Contents
Guidelines
Recent changes
Pages in need
Search
Help
Wiki tools
Wiki tools
Special pages
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs