there’s a syntax difference between macos vs gnu

[[:<:]] and [[:>:]] are tokens that MacOS’s sed inteprets as directional word-boundaries : the first one lets you check you’re matching at the start of a word and the second at the end of a word.
Those let you make sure you’re replacing whole words rather than parts of words (e.g. avoiding to change professor into confessor when you’re trying to replace pro with con).

The exact equivalent in GNU sed would be \< and \>.

However, as someone familiar with regex but not necessarily with the bazillion different implementations, I would suggest you use the more common \b instead of both \< and \>.
It’s a direction-less word boundary which will match if you’re either at the start or the end of a word. It will produce the exact same result in your case (and in most cases) and future maintainers will be more likely to be familiar with it and not go through the struggle you just experienced.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top