Rails和XRegExp:如何在Rails 5中实现XRegExp?

时间:2019-01-26 19:50:23

标签: javascript ruby-on-rails regex xregexp

我目前在IE11中遇到正则表达式问题(为什么有些人仍在使用它使我感到困惑)。而且我在IE的控制台中收到以下错误:

RegExp(/^http/,"i"); //Syntax error in regular expression

我在堆栈溢出with kind of the same issue中发现了一条帖子,该问题的答案是XRegExp可能是关键。

为了进行尝试,我正在寻找一种在rails中安装和实现该库的方法,并找到了名为xregexp-rails

的gem。

所以我想知道如何在rails 5中实现这个gem,以便能够尝试解决我的问题。

更新

尝试安装所述gem在运行捆绑软件,捆绑软件安装和捆绑软件更新后在控制台中显示以下错误:

    Bundler could not find compatible versions for gem "railties":
  In snapshot (Gemfile.lock):
    railties (= 5.1.4)

  In Gemfile:
    coffee-rails (~> 4.2) was resolved to 4.2.2, which depends on
      railties (>= 4.0.0)

    devise was resolved to 4.3.0, which depends on
      railties (< 5.2, >= 4.1.0)

    dotenv-rails was resolved to 2.2.1, which depends on
      railties (< 5.2, >= 3.2)

    factory_girl_rails was resolved to 4.8.0, which depends on
      railties (>= 3.0.0)

    rails (~> 5.1.2) was resolved to 5.1.4, which depends on
      railties (= 5.1.4)

    devise was resolved to 4.3.0, which depends on
      responders was resolved to 2.4.0, which depends on
        railties (< 5.3, >= 4.2.0)

    rspec-rails was resolved to 3.6.0, which depends on
      railties (>= 3.0)

    sass-rails (~> 5.0) was resolved to 5.0.6, which depends on
      railties (< 6, >= 4.0.0)

    web-console (>= 3.3.0) was resolved to 3.5.1, which depends on
      railties (>= 5.0)

    xregexp-rails (>= 1.5.1, ~> 1.5) was resolved to 1.5.1, which depends on
      railties (< 5.0, >= 3.0)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

0 个答案:

没有答案