Alexander Belov,
function x(a, b) {
return a.length == b.length && (new RegExp(a.split("").reduce(function(a, b) {
return a + "(?=.*" + b + ")"
}, ""))).test(b)
};
alert(x("Iowa","oIaw"));
alert(x("Iowa","aIow"));
alert(x("Iowa","stateIowa"));
alert(x("Iowa","Io wa"));