Forum: Ruby-core [ruby-trunk - Bug #8133][Open] Regexp macro %r{} is loosing backslash on "\}"

Posted by jstribny (Josef Stribny) (Guest)
on 2013-03-20 16:22
(Received via mailing list)
Issue #8133 has been reported by jstribny (Josef Stribny).

----------------------------------------
Bug #8133: Regexp macro %r{} is loosing backslash on "\}"
https://bugs.ruby-lang.org/issues/8133

Author: jstribny (Josef Stribny)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: 2.0.0


Hello,

Ruby 2.0.0 is loosing the backslash when used on "\}" string (exact 
match).

How to reproduce in irb:

2.0.0-p0 :003 > %r{\}}
 => /}/
2.0.0-p0 :004 > %r{\{}
 => /\{/

Compared to:

1.9.3p392 :001 > %r{\{}
 => /\{/
1.9.3p392 :002 > %r{\}}
 => /\}/

This shouldn't probably happen.
Posted by Nobuyoshi Nakada (nobu)
on 2013-03-21 03:27
(Received via mailing list)
Issue #8133 has been updated by nobu (Nobuyoshi Nakada).

Status changed from Open to Rejected

There is nothing different, as '}' is not a regexp meta character.
----------------------------------------
Bug #8133: Regexp macro %r{} is loosing backslash on "\}"
https://bugs.ruby-lang.org/issues/8133#change-37778

Author: jstribny (Josef Stribny)
Status: Rejected
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: 2.0.0


Hello,

Ruby 2.0.0 is loosing the backslash when used on "\}" string (exact 
match).

How to reproduce in irb:

2.0.0-p0 :003 > %r{\}}
 => /}/
2.0.0-p0 :004 > %r{\{}
 => /\{/

Compared to:

1.9.3p392 :001 > %r{\{}
 => /\{/
1.9.3p392 :002 > %r{\}}
 => /\}/

This shouldn't probably happen.
Posted by Vít Ondruch (vo_x)
on 2013-03-21 08:13
(Received via mailing list)
Issue #8133 has been updated by vo.x (Vit Ondruch).

Status changed from Rejected to Open

It doesn't look to be issue of regexp but issue of parser:


C:\Projects>irb
irb(main):001:0> a = %r|\}|
=> /\}/
irb(main):002:0> b = %r{\}}
=> /}/
irb(main):003:0> a == b
=> false

a and b are apparently not the same. They used to be the same in Ruby 
1.9.3.
----------------------------------------
Bug #8133: Regexp macro %r{} is loosing backslash on "\}"
https://bugs.ruby-lang.org/issues/8133#change-37785

Author: jstribny (Josef Stribny)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: 2.0.0


Hello,

Ruby 2.0.0 is loosing the backslash when used on "\}" string (exact 
match).

How to reproduce in irb:

2.0.0-p0 :003 > %r{\}}
 => /}/
2.0.0-p0 :004 > %r{\{}
 => /\{/

Compared to:

1.9.3p392 :001 > %r{\{}
 => /\{/
1.9.3p392 :002 > %r{\}}
 => /\}/

This shouldn't probably happen.
Posted by Vít Ondruch (vo_x)
on 2013-03-21 09:47
(Received via mailing list)
Issue #8133 has been updated by vo.x (Vit Ondruch).


nobu (Nobuyoshi Nakada) wrote:
> This issue was solved with changeset r39858.

Thank you.
----------------------------------------
Bug #8133: Regexp macro %r{} is loosing backslash on "\}"
https://bugs.ruby-lang.org/issues/8133#change-37788

Author: jstribny (Josef Stribny)
Status: Closed
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: 2.0.0


Hello,

Ruby 2.0.0 is loosing the backslash when used on "\}" string (exact 
match).

How to reproduce in irb:

2.0.0-p0 :003 > %r{\}}
 => /}/
2.0.0-p0 :004 > %r{\{}
 => /\{/

Compared to:

1.9.3p392 :001 > %r{\{}
 => /\{/
1.9.3p392 :002 > %r{\}}
 => /\}/

This shouldn't probably happen.
Posted by mame (Yusuke Endoh) (Guest)
on 2013-03-21 15:42
(Received via mailing list)
Issue #8133 has been updated by mame (Yusuke Endoh).


Just for information: r39858 introduces the behavior change.
Whether %r{n{3\}}} matches with:

          | "nnn}" | "n{3}}"
----------+--------+---------
1.9.3p392 |  YES   |  NO
2.0.0p0   |  NO    |  YES
trunk     |  YES   |  NO

--
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Bug #8133: Regexp macro %r{} is loosing backslash on "\}"
https://bugs.ruby-lang.org/issues/8133#change-37797

Author: jstribny (Josef Stribny)
Status: Closed
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: 2.0.0


Hello,

Ruby 2.0.0 is loosing the backslash when used on "\}" string (exact 
match).

How to reproduce in irb:

2.0.0-p0 :003 > %r{\}}
 => /}/
2.0.0-p0 :004 > %r{\{}
 => /\{/

Compared to:

1.9.3p392 :001 > %r{\{}
 => /\{/
1.9.3p392 :002 > %r{\}}
 => /\}/

This shouldn't probably happen.
Posted by nagachika (Tomoyuki Chikanaga) (Guest)
on 2013-03-21 17:41
(Received via mailing list)
Issue #8133 has been updated by nagachika (Tomoyuki Chikanaga).


Hmm, is it a bug introduced in 2.0.0?
I personally feel the behavior of 2.0.0 is natural.
----------------------------------------
Bug #8133: Regexp macro %r{} is loosing backslash on "\}"
https://bugs.ruby-lang.org/issues/8133#change-37798

Author: jstribny (Josef Stribny)
Status: Closed
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: 2.0.0


Hello,

Ruby 2.0.0 is loosing the backslash when used on "\}" string (exact 
match).

How to reproduce in irb:

2.0.0-p0 :003 > %r{\}}
 => /}/
2.0.0-p0 :004 > %r{\{}
 => /\{/

Compared to:

1.9.3p392 :001 > %r{\{}
 => /\{/
1.9.3p392 :002 > %r{\}}
 => /\}/

This shouldn't probably happen.
Posted by naruse (Yui NARUSE) (Guest)
on 2013-03-22 08:26
(Received via mailing list)
Issue #8133 has been updated by naruse (Yui NARUSE).


nagachika (Tomoyuki Chikanaga) wrote:
> Hmm, is it a bug introduced in 2.0.0?
> I personally feel the behavior of 2.0.0 is natural.

\} in this case doesn't escape a regexp meta character, it escapes 
closing terminator of %r{...} literal.
----------------------------------------
Bug #8133: Regexp macro %r{} is loosing backslash on "\}"
https://bugs.ruby-lang.org/issues/8133#change-37804

Author: jstribny (Josef Stribny)
Status: Closed
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: 2.0.0


Hello,

Ruby 2.0.0 is loosing the backslash when used on "\}" string (exact 
match).

How to reproduce in irb:

2.0.0-p0 :003 > %r{\}}
 => /}/
2.0.0-p0 :004 > %r{\{}
 => /\{/

Compared to:

1.9.3p392 :001 > %r{\{}
 => /\{/
1.9.3p392 :002 > %r{\}}
 => /\}/

This shouldn't probably happen.
Posted by nagachika (Tomoyuki Chikanaga) (Guest)
on 2013-03-24 18:57
(Received via mailing list)
Issue #8133 has been updated by nagachika (Tomoyuki Chikanaga).


mame (Yusuke Endoh) wrote:
> Just for information: r39858 introduces the behavior change.
> Whether %r{n{3\}}} matches with:
>
>           | "nnn}" | "n{3}}"
> ----------+--------+---------
> 1.9.3p392 |  YES   |  NO
> 2.0.0p0   |  NO    |  YES
> trunk     |  YES   |  NO
>

On my environment the result was exactly opposite.

$ cat regexp_test.rb
re = %r{n{3\}}}
p re
p [re =~ "nnn}", re =~ "n{3}}"]

ruby 1.9.3dev (2011-09-24 revision 33322) [x86_64-darwin10.8.0]
/n{3\}}/
[nil, 0]

ruby 2.0.0p96 (2013-03-25 revision 39918) [x86_64-darwin10.8.0]
/n{3}}/
[0, nil]

ruby 2.1.0dev (2013-03-24 trunk 39908) [x86_64-darwin10.8.0]
/n{3\}}/
[nil, 0]


----------------------------------------
Bug #8133: Regexp macro %r{} is loosing backslash on "\}"
https://bugs.ruby-lang.org/issues/8133#change-37900

Author: jstribny (Josef Stribny)
Status: Closed
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: 2.0.0


Hello,

Ruby 2.0.0 is loosing the backslash when used on "\}" string (exact 
match).

How to reproduce in irb:

2.0.0-p0 :003 > %r{\}}
 => /}/
2.0.0-p0 :004 > %r{\{}
 => /\{/

Compared to:

1.9.3p392 :001 > %r{\{}
 => /\{/
1.9.3p392 :002 > %r{\}}
 => /\}/

This shouldn't probably happen.
Posted by nagachika (Tomoyuki Chikanaga) (Guest)
on 2013-03-24 18:59
(Received via mailing list)
Issue #8133 has been updated by nagachika (Tomoyuki Chikanaga).


naruse (Yui NARUSE) wrote:
> \} in this case doesn't escape a regexp meta character, it escapes closing 
terminator of %r{...} literal.

I agree. It's reasonable.
Thanks.
----------------------------------------
Bug #8133: Regexp macro %r{} is loosing backslash on "\}"
https://bugs.ruby-lang.org/issues/8133#change-37901

Author: jstribny (Josef Stribny)
Status: Closed
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: 2.0.0


Hello,

Ruby 2.0.0 is loosing the backslash when used on "\}" string (exact 
match).

How to reproduce in irb:

2.0.0-p0 :003 > %r{\}}
 => /}/
2.0.0-p0 :004 > %r{\{}
 => /\{/

Compared to:

1.9.3p392 :001 > %r{\{}
 => /\{/
1.9.3p392 :002 > %r{\}}
 => /\}/

This shouldn't probably happen.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.