How to split strings into tokens in Erlang?

I am new in Erlang programming, so I want to know how can I split strings using Erlang Code.
This is my String: MyString = "I Love Erlang Programming";
I want to split above string into a list of tokens.
Please help me, and give me an example if possible.
Thank you.
Last updated:3/14/2016 2:00:38 AM

1 Answers

Tarun Kumar
Tarun Kumar

You can split string according to space existance, like this:
> MyTokens = string:tokens('I Love Erlang Programming', ' ').
This will return a List of tokens like this:
OR we can use any character to split string instead of space.
Example: > MyTokens = string:tokens('I.Love.Erlang.Programming', '.').
Result of above example will be same as the previous example.
I hope it is sufficient to understand.