Project

General

Profile

Actions

Bug #10891

closed

/[[:punct:]]/ POSIX group broken (with string literals?)

Added by tom-lord (Tom Lord) about 9 years ago. Updated almost 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
[ruby-core:68254]

Description

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!

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0