История изменений
Исправление beastie, (текущая версия) :
Не помню, где и когда я их надыбал. Вот тебе выписка из мана:
There are two special cases** of bracket expressions: the bracket expressions ‘[[:<:]]’ and ‘[[:>:]]’ match the null string at the beginning and end of a word, respectively. A word is defined as a sequence of characters starting and ending with a word character which is neither preceded nor followed by word characters. A word character is an alnum character (as defined by isalnum(3)) or an underscore. This is an extension, compatible with but not specified by POSIX, and should be used with caution in software intended to be portable to other systems. The additional word delimiters ‘\<’ and ‘\>’ are provided to ease compatibility with traditional SVR4 systems but are not portable and should be avoided.
ref: http://mdoc.su/o/re_format
Т.ч. кошернее их заменить на [[:<:]]
и [[:>:]]
, но это на 5 символов больше. ;) Ещё можно использовать \b
.
UPD: гуглить по regex word boundary
Исходная версия beastie, :
Не помню, где и когда я их надыбал. Вот тебе выписка из мана:
There are two special cases** of bracket expressions: the bracket expressions ‘[[:<:]]’ and ‘[[:>:]]’ match the null string at the beginning and end of a word, respectively. A word is defined as a sequence of characters starting and ending with a word character which is neither preceded nor followed by word characters. A word character is an alnum character (as defined by isalnum(3)) or an underscore. This is an extension, compatible with but not specified by POSIX, and should be used with caution in software intended to be portable to other systems. The additional word delimiters ‘\<’ and ‘\>’ are provided to ease compatibility with traditional SVR4 systems but are not portable and should be avoided.
ref: http://mdoc.su/o/re_format
Т.ч. кошернее их заменить на [[:<:]]
и [[:>:]]
, но это на 5 символов больше. ;) Ещё можно использовать \b
.