#!/usr/bin/ruby

#
## http://rosettacode.org/wiki/Multisplit
#

func multisplit(sep, str, :opt) {
    sep = sep.map{.escape}.join('|');
    var re = Regex.new(opt{:keep_sep} ? "(#{sep})" : sep);
    str.split(re, -1);
}
 
[false, true].each { |bool|
    say multisplit(%w(== != =), 'a!===b=!=c', keep_sep => bool);
}
