Extended String API
- Source:
Members
(static) ASCII_LETTERS :String
All ASCII letters
Type:
- String
- Source:
(static) ASCII_LOWERCASE :String
All lowercase letters
Type:
- String
- Source:
(static) ASCII_UPPERCASE :String
All uppercase letters
Type:
- String
- Source:
Methods
(private, static) endsWith(s, subs) → {Boolean}
Check if a string s ends with another string subs
Parameters:
Name | Type | Description |
---|---|---|
s |
String | The string to look in |
subs |
String | The string to look for |
- Deprecated:
- Yes
- Source:
Returns:
True if s ends with subs
- Type
- Boolean
(static) format(s, argumentsopt) → {String}
Return a string with {n} replaced with the n-th argument
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
s |
String | The string to format | |
arguments |
Object |
<optional> |
All other arguments are substituted into the string |
- Source:
Returns:
The formatted string
- Type
- String
Example
var s = pc.string.format("Hello {0}", "world");
console.log(s); // Prints "Hello world"
(static) fromCodePoint(…args) → {String}
Get the string for a given code point or set of code points. Polyfill for
fromCodePoint
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
Number |
<repeatable> |
The code points to convert to a string |
- Source:
Returns:
The converted string
- Type
- String
(static) getCodePoint(string, iopt) → {Number}
Get the code point number for a character in a string. Polyfill for
codePointAt
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
string |
String | The string to get the code point from | |
i |
Number |
<optional> |
The index in the string |
- Source:
Returns:
The code point value for the character in the string
- Type
- Number
(static) getCodePoints(string) → {Array.<Number>}
Gets an array of all code points in a string
Parameters:
Name | Type | Description |
---|---|---|
string |
String | The string to get code points from |
- Source:
Returns:
The code points in the string
- Type
- Array.<Number>
(static) getSymbols(string) → {Array.<String>}
Gets an array of all grapheme clusters (visible symbols) in a string. This is needed because
some symbols (such as emoji or accented characters) are actually made up of multiple character codes.
Parameters:
Name | Type | Description |
---|---|---|
string |
String | The string to break into symbols |
- Source:
- See:
Returns:
The symbols in the string
- Type
- Array.<String>
(private, static) startsWith(s, subs) → {Boolean}
Check if a string s starts with another string subs
Parameters:
Name | Type | Description |
---|---|---|
s |
String | The string to look in |
subs |
String | The string to look for |
- Deprecated:
- Yes
- Source:
Returns:
True if s starts with subs
- Type
- Boolean
Example
var s = "abc";
if (pc.string.startsWith(s, "a")) {
console.log('Starts with a');
}
(static) toBool(s, strictopt) → {Boolean}
Convert a string value to a boolean. In non-strict mode (the default), 'true' is converted to true, all other values
are converted to false. In strict mode, 'true' is converted to true, 'false' is converted to false, all other values will throw
an Exception.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
s |
String | The string to convert | |
strict |
Boolean |
<optional> |
In strict mode an Exception is thrown if s is not an accepted string value. Defaults to false |
- Source:
Returns:
The converted value
- Type
- Boolean