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,726
  • 5
  • 43
  • 65

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
  • 226,338
  • 43
  • 373
  • 367
Toto
  • 89,455
  • 62
  • 89
  • 125