JSRegexp is a converter from Ruby Regexp to a valid JavaScript RegExp format
Add this line to your application's Gemfile:
gem 'jsregexp'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jsregexp
JSRegexp.convert(/\Afoo/) # => '^foo'
JSRegexp.convert('/\Gbar/') # => '^bar'
JSRegexp.convert('baz\Z') # => 'baz$'