Methods
(static) endsWith(s) → {string}
return true if s ends with substring
Parameters:
Name | Type | Description |
---|---|---|
s |
string |
Returns:
- Type
- string
Example
endsWith("Minsun", "sun");
// true
endsWith("Minsun", "suns");
// false
endsWith("Minsun", "un")
// true
(static) isBlank(s) → {boolean}
returns true if s is null, empty or contains only whitespace
Parameters:
Name | Type | Description |
---|---|---|
s |
string |
Returns:
- Type
- boolean
Example
isBlank(null);
// => true
isBlank("");
// => true
(static) join(sep, coll) → {string}
returns a string of all elements in coll
Parameters:
Name | Type | Description |
---|---|---|
sep |
* | |
coll |
* |
Returns:
- Type
- string
Example
join([1, 2, 3]);
// => "123"
join(", ", [1, 2, 3]);
// => "1, 2, 3"
join("-", split("hello world", " "));
// => "hello-world"
(static) lowerCase(s) → {string}
returns a string set to lower case
Parameters:
Name | Type | Description |
---|---|---|
s |
string |
Returns:
- Type
- string
Example
lowerCase("Hello");
// => "hello"
lowerCase("ABCD");
// => "abcd"
(static) replace(s, match, replacement) → {string}
replaces all instances of match with replacement in s
Parameters:
Name | Type | Description |
---|---|---|
s |
string | |
match |
string | RegExp | |
replacement |
string |
Returns:
- Type
- string
Example
replace("The color is red", /red/g, "blue");
// => "The color is blue"
replace("banana and mango", "an", "um");
// => "bumuma umd mumgo"
(static) split(s) → {string|RegExp|number}
splits a string on regular expression. JavaScript's limit works
differently to Java's. This implementation mimics Java's.
Parameters:
Name | Type | Description |
---|---|---|
s |
string |
Returns:
-
- Type
- string | RegExp
-
- Type
- number
Example
split("Hello world", " ");
// => ["Hello", "world"]
split("JavaScript is awesome!", " ")
// => ["JavaScript", "is", "awesome!"]
split("q1w2e3r4t5y6u7i8o9p0", /\d+/);
// => ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", ""]
split("q1w2e3r4t5y6u7i8o9p0", /\d+/, -1);
// => ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", ""]
split("q1w2e3r4t5y6u7i8o9p0", /\d+/, 5);
// => ["q", "w", "e", "r", "t5y6u7i8o9p0"]
split("q1w2e3r4t5y6u7i8o9p0", /\d+/, -1);
// => ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", ""]
split("fooxbarybaz", /[xy]/, 2)
// => ["foo", "barybaz"]
split(" q1w2 ", "");
// => [" ", "q", "1", "w", "2", " "]
split("a", "b");
// => ["a"]
split("hello world", " ");
// => ["hello", "world"]
split("foo--bar--baz", "--");
// => ["foo", "bar", "baz"]
(static) startsWith(s) → {string}
return true if s starts with substring
Parameters:
Name | Type | Description |
---|---|---|
s |
string |
Returns:
- Type
- string
Example
startsWith("abcde", "a");
// => true
startsWith("abcde", "b");
// => false
(static) trim(s) → {string}
removes whitespace from both ends of a string
Parameters:
Name | Type | Description |
---|---|---|
s |
string |
Returns:
- Type
- string
Example
trim(" a ");
"a"
(static) triml(s) → {string}
removes whitespace from the start of a string
Parameters:
Name | Type | Description |
---|---|---|
s |
string |
Returns:
- Type
- string
Example
trim(" a");
"a"
(static) trimr(s) → {string}
removes whitespace from the end of a string
Parameters:
Name | Type | Description |
---|---|---|
s |
string |
Returns:
- Type
- string
Example
trim("a ");
"a"
(static) upperCase(s) → {string}
returns a string set to upper case
Parameters:
Name | Type | Description |
---|---|---|
s |
string |
Returns:
- Type
- string
Example
upperCase("Hello");
// => "HELLO"
upperCase("abcd");
// => "ABCD"