I am having quite the difficulty using regex in ruby to split a string along several delimiters these delimiters are:
- ,
- /
- &
- and
each of these delimiters can have any amount of white space on either side of the delimiter but each item can contain a valid space.
a great example that I've been testing against is the string 1, 2 /3 and 4 12
what I would like is something around the lines of "1, 2 /3 and 4 12".split(regex) =>["1", "2", "3", "4 12"]
The closest I've been able to get is /\s*,|\/|&|and \s*/
but this generates ["1", " 2 ", "3 ", "4 12"]
instead of the desired results.
Realize this is very close and I could simply all trim on each item, but being so close and knowing it can be done is sort of driving me mad. Hopefully someone can help me keep the madness at bay.