Refactor comparison into browser-compatible module
Fixed RegExp bug