From: lord.thom@... Date: 2015-02-24T10:03:26+00:00 Subject: [ruby-core:68280] [Ruby trunk - Bug #10891] /[[:punct:]]/ POSIX group broken (with string literals?) Issue #10891 has been updated by Tom Lord. On further investigation, this is a known issue in Onigmo (Ruby 2.x's regexp parser). However, it was apparently "fixed" way back in 2006: https://github.com/k-takata/Onigmo/blob/d0b3173893b9499a4e53ae1da16ba76c06d85571/HISTORY#L584-585 (Note: I can't find a reference to any Oniguruma/Onigmo source control dating back this far, to see the actual commit) ...And yet, it remains an open issue: https://github.com/k-takata/Onigmo/issues/42 ---------------------------------------- Bug #10891: /[[:punct:]]/ POSIX group broken (with string literals?) https://bugs.ruby-lang.org/issues/10891#change-51638 * Author: Tom Lord * Status: Open * Priority: Normal * Assignee: ruby-core * ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- The regular expression: `/[[:punct:]]/` should match the following characters: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ However, it only works for these characters: ! " # % & ' ( ) * , - . / : ; ? @ [ \\ ] _ { } And does not work for these characters: $ + < = > ^ ` | ~ However, this is where it gets really weird... Consider the following: 60.chr == "<" # true 60.chr =~ /[[:punct:]]/ # => 0 "<" =~ /[[:punct:]]/ # => nil So, it seems that the regular expression only fails for string literals! -- https://bugs.ruby-lang.org/