Return to String Function Index
String Function Syntax and Examples
The EXTRACTWORD() function scans an input string for the nth occurrence of a substring. If found, the function returns the substring; otherwise it returns the empty string.
Syntax:
EXTRACTWORD(substring-number, input-string, delimiter-list)
where:
- substring-number is an integer value representing the nth substring within the input string. A "substring" is defined as having a delimiter appear both before and after it in the input string, except for the first substring (which has no leading delimiter) and the last substring (which has no trailing delimiter).
- input-string is the input string.
- delimiter-list is the character, or list of characters, that mark the boundaries of each substring. If a list of characters is supplied, any one or more of the characters can act as a delimiter. The delimiter list must be contained in quotation marks if supplied as a string constant. Note that consecutive delimiters in the input string are counted as a single delimiter.
Example:input: 2002-12-05-17.25.32.000000
IMPORT @sample.dat
{RECORD
{
field1 *\r\n
}
schema1.table1
{
col1 EXTRACTWORD(4, field1, '.-/:')
}}
Results:
schema1.table1.col1 17
Return to String Function Index