capitalize: Difference between revisions
Jump to navigation
Jump to search
m (Text replacement - "source>" to "syntaxhighlight>") |
m (Text replacement - "<source" to "<syntaxhighlight") |
||
Line 8: | Line 8: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
capitalize(input) | capitalize(input) | ||
capitalize(input, treatNumbersSymbolsAsBoundaries) | capitalize(input, treatNumbersSymbolsAsBoundaries) | ||
Line 17: | Line 17: | ||
|example= | |example= | ||
Converting character name. | Converting character name. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: name = getTokenName()]<br> | [r: name = getTokenName()]<br> | ||
[r: capitalize(name)] | [r: capitalize(name)] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Returns: | Returns: | ||
< | <syntaxhighlight lang="mtmacro"> | ||
ichabod crane | ichabod crane | ||
Ichabod Crane | Ichabod Crane | ||
Line 28: | Line 28: | ||
String with numbers and symbols. | String with numbers and symbols. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: capitalize("a 4ever 2/una")] | [r: capitalize("a 4ever 2/una")] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Returns: | Returns: | ||
< | <syntaxhighlight lang="mtmacro"> | ||
A 4Ever 2Una | A 4Ever 2Una | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==== Since 1.8 ==== | ==== Since 1.8 ==== | ||
String with numbers and symbols: | String with numbers and symbols: | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: vLine = "he's sure i'll see you 1st, o'shea"] | [h: vLine = "he's sure i'll see you 1st, o'shea"] | ||
[r: capitalize(vLine)] | [r: capitalize(vLine)] | ||
Line 43: | Line 43: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Returns: | Returns: | ||
< | <syntaxhighlight lang="mtmacro"> | ||
He'S Sure I'Ll See You 1St, O'Shea | He'S Sure I'Ll See You 1St, O'Shea | ||
He's Sure I'll See You 1st, O'shea | He's Sure I'll See You 1st, O'shea |
Latest revision as of 20:47, 14 March 2023
capitalize() Function
• Introduced in version 1.5.7
Returns the passed string back with the first letter of each word capitalized. This means that "bump player health" becomes "Bump Player Health". By default, numbers and symbols in the strings are treated as word boundaries.
Usage
capitalize(input)
capitalize(input, treatNumbersSymbolsAsBoundaries)
Parameters
input
- String to be converted.treatNumbersSymbolsAsBoundaries
- Since 1.8. Whether numbers and symbols should be treated as word boundaries - defaults totrue
(1
).
Example
Converting character name.
[r: name = getTokenName()]<br>
[r: capitalize(name)]
Returns:
ichabod crane
Ichabod Crane
String with numbers and symbols.
[r: capitalize("a 4ever 2/una")]
Returns:
A 4Ever 2Una
Since 1.8
String with numbers and symbols:
[h: vLine = "he's sure i'll see you 1st, o'shea"]
[r: capitalize(vLine)]
[r: capitalize(vLine, 0)]
Returns:
He'S Sure I'Ll See You 1St, O'Shea
He's Sure I'll See You 1st, O'shea
See Also
Version Changes
- 1.5.7 - Added function.
- 1.8 - Added optional param to control treatment of numbers and symbols as word boundaries.