ReQL command reference - RethinkDB
ReQL command: split
Command syntax
string.split([separator, [max_splits]]) → array

Description
Split a string into substrings. With no arguments, will split on whitespace; when called with a string as the first argument, will split using that string as a separator. A maximum number of splits can also be specified. (To specify max_splits while still splitting on whitespace, use null as the separator argument.)
Mimics the behavior of Python’s string.split in edge cases, except
for splitting on the empty string, which instead produces an array of
single-character strings.
Example: Split on whitespace.
r.expr("foo bar bax").split().run(conn);
Result:
Example: Split the entries in a CSV file.
r.expr("12,37,,22,").split(",").run(conn);
Result:
["12", "37", "", "22", ""]
Example: Split a string into characters.
r.expr("mlucy").split("").run(conn);
Result:
["m", "l", "u", "c", "y"]
Example: Split the entries in a CSV file, but only at most 3 times.
r.expr("12,37,,22,").split(",", 3).run(conn);
Result:
Example: Split on whitespace at most once (i.e. get the first word).
r.expr("foo bar bax").split(null, 1).run(conn);
Result:
Related commands
Get more help
Couldn't find what you were looking for?
- Ask a question on Stack Overflow
- Chat with us and our community on Slack
- Talk to the team on IRC on #rethinkdb@freenode.net — via Webchat
- Ping @rethinkdb on Twitter
- Post an issue on the documentation issue tracker on GitHub