\b in regexp is word boundary, not backspace

I was looking at the documentation for regular expressions here:

https://crystal-lang.org/reference/1.18/syntax_and_semantics/literals/regex.html

It says that \b is the escape sequence for backspace, but I am pretty sure that is wrong. Crystal now uses PCRE2, which means that \b is actually a word boundary, and my testing shows this to be the case.

It’s possible I misunderstood something, but if not, I hope the doc can be changed.

1 Like

Good catch.

Please click the edit pen


Edit the section on GitHub web interface

Then commit and send a pull request.

Thanks! I’d never done something like that before; I hope I did it right.

1 Like

It’s both, inside character classes \b is backspace (yes, it’s weird)

3 Likes

That’s interesting. So maybe rather than removing that line from the docs, it should be explained in more detail.