How to split a string into a list with multiple values, using Erlang?

Viewed 4739

When I read specific lines from a .txt file, I get a string like this one:

"Test,Test2,Test3,Test4,Test5,Test6"

I want to convert this string so it can fill a list, which looks like this:

List = [A, B, C, D, E, F]

Inserting values in such list can be done like this, for example:

["A", "B", "C", "D", "E", "F"]

But when I try to insert the string from the file, it ends up being stored only in the A variable, as the content is not being split. The other variables don't get the expected values.

What I'm getting:

List = ["Test,Test2,Test3,Test4,Test5,Test6", "B", "C", "D", "E", "F"]

What I want:

List = ["Test", "Test2", "Test3", "Test4", "Test5", "Test6"]

So basically I'm asking help with splitting a string to separate values by a certain char in Erlang!

Thanks for any help!

1 Answers
Related