I am having difficulty using a regular expression in ruby to split a string along multiple delimiters, these delimiters:
each of these delimiters can have any number of spaces on either side of the delimiter, but each element can contain a valid space. great example i tested is a line1, 2 /3 and 4 12
what i would like is something like strings "1, 2 /3 and 4 12".split(regex) =>["1", "2", "3", "4 12"]
The closest I could get is /\s*,|\/|&|and \s*/, but instead of the desired results, it generates ["1", " 2 ", "3 ", "4 12"].
Understand that it is very close, and I could just cut off every subject, but be so close and knowing that it can be done, it’s conscience to me crazy. Hope someone can help me keep the madness in fear.
source
share