The SPLIT() function splits a string into an array by the specified delimiter, returning a string array where each element is a delimiter-separated part of the original string. Usage includes: splitting a comma-separated list of values into an array, extracting filenames from paths, and splitting email addresses into usernames and domains.
SPLIT() function in Oracle
The SPLIT() function is used to separate strings by specified symbols into arrays. The syntax is as follows:
<code>SPLIT(string, delimiter)</code>
Parameters:
Return value:
Returns an array of strings in which each element is the delimiter-delimited portion of the original string.
Usage:
The SPLIT() function can be used to solve various string processing tasks, for example:
Comma separated list of values split into array:
<code>SELECT SPLIT('name1,name2,name3', ',') FROM dual;</code>
Extract filename from path:
<code>SELECT SPLIT('path/to/filename.ext', '/')[-1] FROM dual;</code>
Split email address into Username and Domain:
<code>SELECT SPLIT('username@domain.com', '@')[1] FROM dual;</code>
Notes:
The above is the detailed content of How to use split() function in oracle. For more information, please follow other related articles on the PHP Chinese website!