Skip to content

Commit

Permalink
Comment about a RUBY BUG (!!!) code limitation
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
Tom Lord committed Feb 23, 2015
1 parent 449e3d1 commit 2aab0a1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/regexp-examples/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 | ['_']
Expand Down

0 comments on commit 2aab0a1

Please sign in to comment.