https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112013-03-21T11:26:47ZRuby Issue Tracking SystemRuby master - Bug #8133: Regexp macro %r{} is loosing backslash on "\}"https://bugs.ruby-lang.org/issues/8133?journal_id=377782013-03-21T11:26:47Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>There is nothing different, as '}' is not a regexp meta character.</p> Ruby master - Bug #8133: Regexp macro %r{} is loosing backslash on "\}"https://bugs.ruby-lang.org/issues/8133?journal_id=377852013-03-21T16:13:02Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<ul><li><strong>Status</strong> changed from <i>Rejected</i> to <i>Open</i></li></ul><p>It doesn't look to be issue of regexp but issue of parser:</p>
<p>C:\Projects>irb<br>
irb(main):001:0> a = %r|}|<br>
=> /}/<br>
irb(main):002:0> b = %r{}}<br>
=> /}/<br>
irb(main):003:0> a == b<br>
=> false</p>
<p>a and b are apparently not the same. They used to be the same in Ruby 1.9.3.</p> Ruby master - Bug #8133: Regexp macro %r{} is loosing backslash on "\}"https://bugs.ruby-lang.org/issues/8133?journal_id=377862013-03-21T16:48:14Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r39858.<br>
Josef, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>parse.y: escape all closing parens</p>
<ul>
<li>parse.y (simple_re_meta): escape all closing characters, not only<br>
round parenthesis. <a href="/issues/8133">[ruby-core:53578]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Regexp macro %r{} is loosing backslash on "\}" (Closed)" href="https://bugs.ruby-lang.org/issues/8133">#8133</a>]</li>
</ul> Ruby master - Bug #8133: Regexp macro %r{} is loosing backslash on "\}"https://bugs.ruby-lang.org/issues/8133?journal_id=377882013-03-21T17:46:55Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<ul></ul><p>nobu (Nobuyoshi Nakada) wrote:</p>
<blockquote>
<p>This issue was solved with changeset r39858.</p>
</blockquote>
<p>Thank you.</p> Ruby master - Bug #8133: Regexp macro %r{} is loosing backslash on "\}"https://bugs.ruby-lang.org/issues/8133?journal_id=377972013-03-21T23:41:13Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>Just for information: r39858 introduces the behavior change.<br>
Whether %r{n{3}}} matches with:</p>
<pre><code> | "nnn}" | "n{3}}"
</code></pre>
<p>----------+--------+---------<br>
1.9.3p392 | YES | NO<br>
2.0.0p0 | NO | YES<br>
trunk | YES | NO</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Bug #8133: Regexp macro %r{} is loosing backslash on "\}"https://bugs.ruby-lang.org/issues/8133?journal_id=377982013-03-22T01:40:53Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul></ul><p>Hmm, is it a bug introduced in 2.0.0?<br>
I personally feel the behavior of 2.0.0 is natural.</p> Ruby master - Bug #8133: Regexp macro %r{} is loosing backslash on "\}"https://bugs.ruby-lang.org/issues/8133?journal_id=378042013-03-22T16:26:26Znaruse (Yui NARUSE)naruse@airemix.jp
<ul></ul><p>nagachika (Tomoyuki Chikanaga) wrote:</p>
<blockquote>
<p>Hmm, is it a bug introduced in 2.0.0?<br>
I personally feel the behavior of 2.0.0 is natural.</p>
</blockquote>
<p>} in this case doesn't escape a regexp meta character, it escapes closing terminator of %r{...} literal.</p> Ruby master - Bug #8133: Regexp macro %r{} is loosing backslash on "\}"https://bugs.ruby-lang.org/issues/8133?journal_id=379002013-03-25T02:56:57Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul></ul><p>mame (Yusuke Endoh) wrote:</p>
<blockquote>
<p>Just for information: r39858 introduces the behavior change.<br>
Whether %r{n{3}}} matches with:</p>
<pre><code> | "nnn}" | "n{3}}"
</code></pre>
<p>----------+--------+---------<br>
1.9.3p392 | YES | NO<br>
2.0.0p0 | NO | YES<br>
trunk | YES | NO</p>
</blockquote>
<p>On my environment the result was exactly opposite.</p>
<p>$ cat regexp_test.rb<br>
re = %r{n{3}}}<br>
p re<br>
p [re =~ "nnn}", re =~ "n{3}}"]</p>
<p>ruby 1.9.3dev (2011-09-24 revision 33322) [x86_64-darwin10.8.0]<br>
/n{3}}/<br>
[nil, 0]</p>
<p>ruby 2.0.0p96 (2013-03-25 revision 39918) [x86_64-darwin10.8.0]<br>
/n{3}}/<br>
[0, nil]</p>
<p>ruby 2.1.0dev (2013-03-24 trunk 39908) [x86_64-darwin10.8.0]<br>
/n{3}}/<br>
[nil, 0]</p> Ruby master - Bug #8133: Regexp macro %r{} is loosing backslash on "\}"https://bugs.ruby-lang.org/issues/8133?journal_id=379012013-03-25T02:59:14Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul></ul><p>naruse (Yui NARUSE) wrote:</p>
<blockquote>
<p>} in this case doesn't escape a regexp meta character, it escapes closing terminator of %r{...} literal.</p>
</blockquote>
<p>I agree. It's reasonable.<br>
Thanks.</p>