From 2aab0a1c5bc64baf6b81ebdea343a8fcc254cef5 Mon Sep 17 00:00:00 2001 From: Tom Lord Date: Mon, 23 Feb 2015 12:08:40 +0000 Subject: [PATCH] Comment about a RUBY BUG (!!!) code limitation Here is the bug in action: 60.chr # => "<" 60.chr =~ /[[:punct:]]/ # => 0 "<" =~ /[[:punct:]]/ # => nil (wtf!!) It seems that certain string "literals* are not matched by the /[[:punct:]]/ POSIX group, that should be! --- lib/regexp-examples/constants.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/regexp-examples/constants.rb b/lib/regexp-examples/constants.rb index cc0b448..f4955c5 100644 --- a/lib/regexp-examples/constants.rb +++ b/lib/regexp-examples/constants.rb @@ -35,6 +35,9 @@ module CharSets Lower = Array('a'..'z') Upper = Array('A'..'Z') Digit = Array('0'..'9') + # Note: Punct should also include the following chars: $ + < = > ^ ` | ~ + # I.e. Punct = %w(! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \\ ] ^ _ ` { | } ~) + # However, due to a ruby bug (!!) these do not work properly at the moment! Punct = %w(! " # % & ' ( ) * , - . / : ; ? @ [ \\ ] _ { }) Hex = Array('a'..'f') | Array('A'..'F') | Digit Word = Lower | Upper | Digit | ['_']