Project

General

Profile

Actions

Bug #4044

closed

Regex matching errors when using \W character class and /i option

Added by ben_h (Ben Hoskings) over 13 years ago. Updated about 8 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
Backport:
[ruby-core:33139]

Description

=begin
Hi all,

Josh Bassett and I just discovered an issue with regex matches on ruby-1.9.2p0. (We reduced it while we were hacking on gemcutter.)

The case-insensitive (/i) option together with the non-word character class (\W) match inconsistently against the alphabet. Specifically the regex doesn't match properly against the letters 'k' and 's'.

The following expression demonstrates the problem in irb:

 puts ('a'..'z').to_a.map {|c| [c, c.ord, c[/[^\W]/i] ].inspect }

As a reference, the following two expressions are working properly:

 puts ('a'..'z').to_a.map {|c| [c, c.ord, c[/[^\W]/] ].inspect }
 puts ('a'..'z').to_a.map {|c| [c, c.ord, c[/[\w]/i] ].inspect }

Cheers
Ben Hoskings & Josh Bassett
=end


Related issues 4 (0 open4 closed)

Has duplicate Ruby master - Bug #5871: regexp \W matches some word characters when inside a case-insensitive character classRejected01/10/2012Actions
Has duplicate Ruby master - Bug #7534: /(?i:[\W])/ and /(?i:[\w])/ both match "s"Closed12/08/2012Actions
Has duplicate Ruby master - Bug #7533: Oniguruma hates the letter 's' :(Closednaruse (Yui NARUSE)12/08/2012Actions
Has duplicate Ruby master - Bug #9087: swallowing "s" letters when "i" flag is onClosed11/06/2013Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0