Просто разделите свой вход в соответствии с одним или несколькими символами пробела.
> "This is a sentence I'm currently writing, potentially with punctuation dotted in: item1, item2, item3. That is all.".split(/\s+/)
=> ["This", "is", "a", "sentence", "I'm", "currently", "writing,", "potentially", "with", "punctuation", "dotted", "in:", "item1,", "item2,", "item3.", "That", "is", "all."]
> "This is a sentence I'm currently writing, potentially with punctuation dotted in: item1, item2, item3. That is all.".split()
=> ["This", "is", "a", "sentence", "I'm", "currently", "writing,", "potentially", "with", "punctuation", "dotted", "in:", "item1,", "item2,", "item3.", "That", "is", "all."]
ИЛИ
Матч один или более не пробельные символы.
> "This is a sentence I'm currently writing, potentially with punctuation dotted in: item1, item2, item3. That is all.".scan(/\S+/)
=> ["This", "is", "a", "sentence", "I'm", "currently", "writing,", "potentially", "with", "punctuation", "dotted", "in:", "item1,", "item2,", "item3.", "That", "is", "all."]
просто разделить в соответствии с этим '\ S +' регулярное выражение. или используйте 'string.split()' –
Напишите «так далее». Ваш вопрос неоднозначен. Мы не можем сказать, что вы хотите после этого. И, каков ваш вопрос? – sawa
Вы хотите «писать» или «писать», 'in:' или 'in' ...? – Toto