Backspace in strings and patterns

Interesting. Not what I expected. This is Ruby 1.8.6.

irb

irb(main):001:0> str = "abx\bc"
=> "abx\bc"
irb(main):002:0> str.length
=> 5
irb(main):003:0> s = str.sub(/.\b/, '')
=> "ab\bc"
irb(main):004:0> s.length
=> 4
irb(main):005:0> s = str.sub(/.\x08/, '')
=> "abc"
irb(main):006:0> s.length
=> 3
irb(main):007:0>

Backspace character representation in ASCII, UTF-8, etc. is 8.

Jeffrey

Interesting. Not what I expected. This is Ruby 1.8.6.

Inside a rexexp, \b is not a backspace (except in a character class).
it means word boundary.

Fred