Description
Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive). Negative offsets can be used to provide an offset starting from the end of the string.Syntax
Parameters
The key containing the string value
The starting offset (0-based). Negative values count from the end of the string
The ending offset (inclusive). Negative values count from the end of the string
Returns
The substring determined by the start and end offsets
Examples
Basic Usage
Using Negative Offsets
Get Entire String
Extract Specific Parts
Non-Existent Key
Out of Range Offsets
Notes
- Offsets are zero-based
- Both start and end offsets are inclusive
- Negative offsets count from the end: -1 is the last character, -2 is the second to last, etc.
- If start is larger than the end of the string, an empty string is returned
- If end is larger than the end of the string, the end of the string is used
- Time complexity is O(N) where N is the length of the returned string