[ruby-core:93600] [Ruby master Bug#10891] /[[:punct:]]/ POSIX group broken (with string literals?)
From:
merch-redmine@...
Date:
2019-07-08 01:07:54 UTC
List:
ruby-core #93600
Issue #10891 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Feedback to Closed
This was apparently fixed between Ruby 2.3 and 2.4:
```
$ ruby23 -e 'p("<".force_encoding("UTF-8") =~ /[[:punct:]]/)'
nil
$ ruby24 -e 'p("<".force_encoding("UTF-8") =~ /[[:punct:]]/)'
0
```
----------------------------------------
Bug #10891: /[[:punct:]]/ POSIX group broken (with string literals?)
https://bugs.ruby-lang.org/issues/10891#change-79193
* Author: tom-lord (Tom Lord)
* Status: Closed
* Priority: Normal
* Assignee: naruse (Yui NARUSE)
* Target version:
* 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/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>