Namespace fiveui.string
Defined in: prelude.js.
Constructor Attributes | Constructor Name and Description |
---|---|
String-specific utilities. |
Method Attributes | Method Name and Description |
---|---|
<static> |
fiveui.string.isTitleCase(str)
A simple heuristic check to see if a string is in Title Case. |
<static> |
fiveui.string.tokens(s)
Tokenize a string on whitespace. |
<static> |
fiveui.string.trim(s)
Non-destructively removes whitespace from the start and end of a string. |
Method Detail
<static>
{!boolean}
fiveui.string.isTitleCase(str)
A simple heuristic check to see if a string is in Title Case.
This does not perform an exhaustive grammatical analysis, and as such, it is prone to generating false-positives in some cases. In particular, it only has a short 'white list' of articles, conjections, and prepositions that are allowed to be in lower case.
fiveui.string.isTitleCase('Under the Olive Tree') === true
- Parameters:
- {!string} str
- The string to check.
- Returns:
- {!boolean} true if the string is in title case, false if it is not.
<static>
{string[]>}
fiveui.string.tokens(s)
Tokenize a string on whitespace.
var tokens = fiveui.string.tokens('Under the Olive Tree'); tokens //> [ 'Under', 'the', 'Olive', 'Tree' ]
- Parameters:
- {!string} s
- The string to tokenize.
- Returns:
- {string[]>} An array of substrings.
<static>
{string}
fiveui.string.trim(s)
Non-destructively removes whitespace from the start and end of a string.
- Parameters:
- {string} s Optional
- The string to trim of whitespace.
- Returns:
- {string} The input string, without leading or trailing whitespace. Returns null if you gave it null.