Methods
(static) string_format(pattern, toReplace) → {String}
- Source:
- Since:
- 0.1.0
Build a new string using provided pattern with x
mark representing
each value placeholder. Accepts 3 different type of value containers:
Array, String and Number.
Examples
string_pattern('+x (x) x-x', ['381', '62', '555', '333'])
// => '+381 (62) 555-333'
string_pattern('xxxx-xxxx-xxxx-xxxx', 4242424242424242);
// => '4242-4242-4242-4242'
string_pattern('xxx-xxx')('123456');
// => '123-456'
string_pattern('x@x.x')(['stefanlazarevic.contact', 'gmail', 'com']);
// => 'stefanlazarevic.contact@gmail.com'
Parameters:
Name | Type | Description |
---|---|---|
pattern |
String | A pattern that will be fullfilled. |
toReplace |
Array | Number | String |
Throws:
TypeError
Returns:
New string with fullfilled pattern placeholders.
- Type
- String
(static) stripNonNumeric(value) → {String}
- Source:
- Since:
- 0.1.0
_trimNonNumeric
Replace all characters that are not in range from 0 - 9 from a string.
Example
stripNonNumeric('4242-4242-4242-4242'); // => '4242424242424242'
stripNonNumeric('+(381) 555-333'); // '381555333'
Parameters:
Name | Type | Description |
---|---|---|
value |
String | Value to strip. |
Returns:
Stripped string.
- Type
- String
(static) trim(value) → {String}
- Source:
- Since:
- 0.1.0
The string_trim() method returns the string stripped of whitespace from both ends. string_trim() does not affect the value of the * string itself.
Example
trim(" Stefan Lazarevic "); // => "Stefan Lazarevic"
Parameters:
Name | Type | Description |
---|---|---|
value |
String | String value to trim. |
Returns:
Trimmed string.
- Type
- String