0

Is there a difference between [^\b] and .?

I was modifying some code created by someone else that included this no-word-boundary-character-class ([^\b]). and am not able to find a difference between that and wildcard . (this is in ruby).

My assumption was that [^\b]+ when applied to the string hello world should match hello and stop before the space, (as that is where there is a word boundary.

My observation is that it seems to just match everything. rubular link.

What should be happening here?

Mike H-R
  • 7,147
  • 5
  • 37
  • 58

1 Answers1

2

[\b] means backspace and [^\b] not a backspace

\b is not a character, it can't be included in a character class.

The negation of a word boundary is \B

Sergio Tulentsev
  • 210,238
  • 40
  • 347
  • 343
Toto
  • 83,193
  • 59
  • 77
  • 109