SparkR (version 2.1.2)

substring_index: substring_index

Description

Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything the left of the final delimiter (counting from left) is returned. If count is negative, every to the right of the final delimiter (counting from the right) is returned. substring_index performs a case-sensitive match when searching for delim.

Usage

substring_index(x, delim, count)

# S4 method for Column,character,numeric substring_index(x, delim, count)

Arguments

x

a Column.

delim

a delimiter string.

count

number of occurrences of delim before the substring is returned. A positive number means counting from the left, while negative means counting from the right.

See Also

Other string_funcs: ascii, base64, concat_ws, concat, decode, encode, format_number, format_string, initcap, instr, length, levenshtein, locate, lower, lpad, ltrim, regexp_extract, regexp_replace, reverse, rpad, rtrim, soundex, translate, trim, unbase64, upper

Examples

Run this code
# NOT RUN {
substring_index(df$c, '.', 2)
substring_index(df$c, '.', -1)
# }

Run the code above in your browser using DataCamp Workspace