I suspect that it very rarely makes a difference whether you use (the more common)
or (the more specific) <
and >
, but I can think of an example where it would. This is quite contrived, and I suspect that in most real-world regex use it wouldn't make a difference, but this should demonstrate that it at least could make a difference in some cases.
If I have the following text:
this is his pig
and I want to know if /is/
matches, it wouldn't matter if I instead used /<is>/
or I instead used />is</
But what if my text was instead
is this his pig
There's no longer a word-final boundary before the 'is', only a word-initial boundary. Using /is/
matches, and of course /<is>/
does too, but />is</
does not.
In real life, though, I think it is not common that you really need to be able to make this distinction, which is why (at least outside of sed)
is the normal word boundary marker for regular expressions.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…