The split()
method is used to split a string based on the given pattern.
String.split(str, pat)
str
: The string to split.pat
: The pattern to use to split the string. The pattern can be a regex or a string.The method returns a list.
string = "hello educative"pattern = "\s"split_string = String.split(string, pattern)IO.inspect split_string
String.split()
method.Free Resources