substring_index {SparkR}R Documentation

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 signature '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.

Note

substring_index since 1.5.0

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

## Not run: 
##D substring_index(df$c, '.', 2)
##D substring_index(df$c, '.', -1)
## End(Not run)

[Package SparkR version 2.2.2 Index]