constmyArray = text.split(""); Try it Yourself » Use the limit parameter: constmyArray = text.split(" ",3); Try it Yourself » More examples below. Description Thesplit()method splits a string into an array of substrings.
txt ="apple#banana#cherry#orange" # setting the maxsplit parameter to 1, will return a list with 2 elements! x = txt.split("#",1) print(x) Try it Yourself » ❮ String Methods Track your progress - it's free! Log inSign Up...
compareOptional. The type of string comparison. Possible values: -1: Use the setting of Option Compare 0: Binary comparison 1: Textual comparison 2: Comparison based on info in your database Technical Details Works in:From Access 2000
txt ="apple, banana, cherry" # setting the maxsplit parameter to 1, will return a list with 2 elements! x = txt.rsplit(", ",1) print(x) Try it Yourself » ❮ String Methods Track your progress - it's free! Log inSign Up...