The way I understand things is in relation to other things: Analogy: what can it be compared to? Absence: what would we have to do without it? Example: how does it work?
Accessibility First DevRel. I focus on ensuring content created, events held and company assets are as accessible as possible, for as many people as possible.
Yes so in "The Lion Roared" the matches would be where the pipes are:
T|h|e L|i|o|n R|o|a|r|e|d
and for the original \b the matches would be
|The| |Lion| |Roared|
There is a difference on how this matches that I didn't explain very well, it is between to characters (so at a boundary) that it matches.
So what it gives you is the positions of where the boundaries are. (so instead of returning positions and then the letters matched / groups you will only ever get back the positions (I think, long time since I used it).
I don't think I have ever found a use for \B but \b can be really useful for splitting strings into words.
Thanks, @inhuofficial ! Can you show me an example of
\B
Not word boundary using the same format with the sentence ""The lion roared"?Yes so in "The Lion Roared" the matches would be where the pipes are:
T|h|e L|i|o|n R|o|a|r|e|d
and for the original
\b
the matches would be|The| |Lion| |Roared|
There is a difference on how this matches that I didn't explain very well, it is between to characters (so at a boundary) that it matches.
So what it gives you is the positions of where the boundaries are. (so instead of returning positions and then the letters matched / groups you will only ever get back the positions (I think, long time since I used it).
I don't think I have ever found a use for
\B
but\b
can be really useful for splitting strings into words.See: regex101.com/r/yVG7Gb/1 for
\b
and regex101.com/r/vvGd1d/1 for\B