Home > DeveloperSection > Forums > How to split strings into tokens in Erlang?
Ashish Pandey

Total Post:128

Posted on    March-14-2016 1:32 AM

 erlang erlang 

 1 Reply(s)
 660  View(s)
Rate this:
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.

Tarun Kumar

Total Post:214

Posted on    March-14-2016 2:00 AM

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.

Don't want to miss updates? Please click the below button!

Follow MindStick