HOW TO SPLIT STRINGS INTO TOKENS IN ERLANG?

Ashish Pandey

Total Post:128

Points:898
Posted by  Ashish Pandey
erlang 
 731  View(s)
Ratings:
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.
  1. Tarun Kumar

    Post:214

    Points:1642
    Re: How to split strings into tokens in Erlang?

    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:
    ["I","Love","Erlang","Programming"]
    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!