If I run this in a 1.8.7 console:
$ irb-ruby-1.8.7-p330
1.8.7 :001 > "0a" =~ /\h\h/
=> nil
And if I run the same in a 1.9.2 console:
$ irb-ruby-1.9.2-p290
1.9.2p290 :001 > "0a" =~ /\h\h/
=> 0
:/
If I run this in a 1.8.7 console:
$ irb-ruby-1.8.7-p330
1.8.7 :001 > "0a" =~ /\h\h/
=> nil
And if I run the same in a 1.9.2 console:
$ irb-ruby-1.9.2-p290
1.9.2p290 :001 > "0a" =~ /\h\h/
=> 0
:/
You're right that \h
doesn't seem to be recognised by the standard Ruby 1.8.7 regexp library. This can be confirmed using Rubular. If you need 1.8 compatibility in your code without using any additional gems I think your only alternative is to use an equivalent character class [0-9a-fA-F]
.