Fixed problem with RegExps in Ruby and JS