Split a string.

Share:

Description

Return a list of character vectors of the words in the string, using sep as the delimiter string.

Usage

1
pystr_split(str, sep = " ", maxsplit = nchar(str) - 1)

Arguments

str

A character vector.

sep

A character string.

maxsplit

A numeric integer.

Details

If maxsplit is given, at most maxsplit splits are done (thus, the character vector will have at most maxsplit + 1 elements). If maxsplit is not specified, then there is no limit on the number of splits (all possible splits are made). If sep is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings. The sep argument may consist of multiple characters. If sep is not specified, any whitespace string is a separator. Splitting an empty string returns an empty string.

Value

A list of character vectors.

References

https://docs.python.org/3/library/stdtypes.html#str.split

See Also

pystr_join, pystr_rsplit

Examples

1
2
3
4
pystr_split("www.example.com", ".")
pystr_split("123123123", "2", 2)
pystr_split("1,,2,3", ",")
pystr_split("a--b--c", "--")

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.