#942 [Newbie] Str.split

f_lombardo Thu 28 Jan 2010

Hi to all,

I'm just a novice in Fantom programming, and I have a stupid question. I saw that Str.split accepts only one character as the separator. Why this choose? What if I'd need to split my string around a list of separators?

Thanks a lot.

Bye

Franco

brian Thu 28 Jan 2010

For anything more complex, use sys::Regex

f_lombardo Fri 29 Jan 2010

Oh, yes, you can write Regex("[,;]").split(myString)

I know that it's difficult to get sense from my poor English, but in my question I was guessing mainly about the design choice: it would be better to write myString.split("[,;]") don't you think?

(Ok, ok, it's just a silly question :-)

Thanks

Bye

Franco

andy Fri 29 Jan 2010

I could see the case for multiple delimiters in Str.split - but I don't think its worth complicating the common case of single delimiter (common for me at least...) - when the alternative is pretty simple as well, and much more flexible.

Login or Signup to reply.