Substrings
Three functions are available to return part of a string. The substring function returns a substring based on a starting position (starting at 1 not 0) and optionally a length. For example:
substring("query", 2, 3)returns the string uer. If no length is specified, the function returns the rest of the string. For example:
substring("query", 2)returns uery.
The substring-before function returns all the characters of a string that occur before the first occurrence of another specified string. The substring-after function returns all the characters of a string that occur after the first occurrence of another specified string. Table 17-4 shows examples of the substring functions.
Table 17-4. Examples of the substring functions
|
Example |
Return value |
|---|---|
|
|
|
|
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access