I wanted to test the workings of \B
specifically, across different
engines that should all be handled the same.
I needed to do this to feel confident in using this construct.
The regex engines are: Perl, PHP, JS, and Boost.
These engines should ALL produce the exact same result.
But they don't.
In theory, \B should match everywhere \b doesn't.
The list below show the results using the exact same regex on the different engines.
To me, it looks like PHP and JavaScript work as per definition,
but Perl and Boost are slightly different.
If anyone can validate these results and/or shed light on whether any of
this is the result of bugs.
Or, possibly there is a misconception of the definitions of \b and \B
as, for these engines, they absolutely are supposed to be exactly the same.
Thanks for your time!
(the simple code to produce this output is not included, but can be if needed)
Target = ' ssssssssssssss '
Replacement = '<>'
==================================================
PHP 7.03
\b = ' <>ssssssssssssss<> '
\B = '<> <> <> s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s <>'
(?!\b) = '<> <> <> s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s <>'
(?<!\b) = '<> <> <> s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s <>'
(?!\B) = ' <>ssssssssssssss<> '
(?<!\B) = ' <>ssssssssssssss<> '
=======================================
Perl 5.20
\b = ' <>ssssssssssssss<> '
\B = '<> <> <> s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s '
(?!\b) = '<> <> <> s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s <>'
(?<!\b) = '<> <> <> s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s <>'
(?!\B) = ' <>ssssssssssssss<> '
(?<!\B) = ' <>ssssssssssssss<> '
========================================
Boost 1.64
\b = ' <>ssssssssssssss<> '
\B = ' <> <> s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s '
(?!\b) = '<> <> <> s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s <>'
(?<!\b) = '<> <> <> s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s <>'
(?!\B) = '<> <>ssssssssssssss<> <>'
(?<!\B) = '<> <>ssssssssssssss<> <>'
=====================================
JavaScript
\b = ' <>ssssssssssssss<> '
\B = '<> <> <> s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s <>'
(?!\b) = '<> <> <> s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s<>s <>'
(?!\B) = ' <>ssssssssssssss<> '