Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Ruby 1.8.7 中,以下正则表达式警告:嵌套重复运算符 + 和 * 被替换为 '*'。
^(\w+\.\w+)\|(\w+\.\w+)\n+*$
它在 Ruby 2.0 中可以工作吗?
http://rubular.com/r/nRUSP5LNZA
嵌套运算符可以工作,但由于无用而被警告。\n+*方法:
\n+*
\n
这相当于一个更简单的表达式\n*,这意味着:
\n*
没有理由使用\n+*. Ruby 正则表达式引擎在 Ruby 1.9 和 Ruby 2.0 中被替换,如果有任何差异,那么很简单,新引擎不会像旧引擎那样检查警告。