means transition from "word character" to "non-word character" or vice versa. Word characters are alphanumeric characters, plus underscore, _
. ^
is not a word character, nor is
(space), so the transition from one to another is not a word boundary; as observed, it matches B
, not
. If you want a space specific check, you'd need to explicitly use look-ahead (?=)
or look-behind (?<=)
assertions (possibly negated, depending on use case) with s
/S
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…