Methods
(static) sliceString(string, beginIndex, endIndex) → {string}
- Source:
- Since:
- 0.5.0
- See:
Return the portion of the provided string between the provided indices (first included, second excluded).
Note that indices can be negative.
(named sliceString
to avoid conflict with Array.prototype.slice
)
Example
> sliceString('0123456789', 3)
'3456789'
> sliceString('0123456789', 3, 5)
'34'
> sliceString('0123456789', 3, -1)
'345678'
Parameters:
Name | Type | Description |
---|---|---|
string |
string | |
beginIndex |
number | The zero-based index at which to begin extraction |
endIndex |
number | Optional. The zero-based index before which to end extraction. If negative, starts counting from the end. |
Returns:
- Type
- string
(static) trim(string) → {string}
- Source:
- Since:
- 0.1.0
- See:
Return a string by trimming white space from the provided string
Example
> trim(' abc \n ')
'abc'
Parameters:
Name | Type | Description |
---|---|---|
string |
string |
Returns:
- Type
- string