I suspect that this rarely matters if you use (more general) \b or (more specific) \< and \> , but I can come up with an example where it will be. This is pretty far-fetched, and I suspect that in most cases the use of regular expressions in the real world will not be affected, but it should demonstrate that it can at least make a difference in some cases.
If I have the following text:
this is his pig
and I want to know if /\bis\b/ matches, it doesnβt matter if I used /\<is\>/ instead or /\>is\</
But what if my text was instead
is this his pig
Now before the word "is" is no longer the word-final boundary, but only the word-initial boundary. Using /\bis\b/ appropriate, and of course /\<is\>/ too, but /\>is\</ does not work.
In real life, however, I think itβs not that you really need to be able to make this distinction, so (at least outside sed) \b is a regular word boundary marker for regular expressions.
source share