You can get split to split everything you want, including regex. Something like:
s.split( /\s|==|!=/ )
... may be the beginning.
Disclaimer: regexen makes my head hurt. I tested it now and it works against your example.
UPDATE: None. split always skips that it splits, so the above code loses == and! = from your example. (Monoceres code works fine.)
But for some reason, if you enclose the delimiter in a regular expression in brackets, it stores the thing in the answer array instead of just splitting it. I donโt know if this is a mistake, a function or some kind of smart construction that I do not appreciate properly.
So in fact you need to:
s.split( /\s|(==)|(!=)/ )
But this hardly explains the code itself. And for everyone I know, this does not work in 1.9.
Shadowfirebird
source share