I am looking for some word boundary to cover those 3 cases:
Is there something like that since \b covers also -,/ etc.?
Would like to replace \b in this pattern by something described above:
(\b\d*\sx\s|\b\d*x|\b)
Word Boundary: \b The word boundary \b matches positions where one side is a word character (usually a letter, digit or underscore—but see below for variations across engines) and the other side is not a word character (for instance, it may be the beginning of the string or a space character).
Matches only at the start of the string. \b. Matches the empty string, but only at the beginning or end of a word. A word is defined as a sequence of word characters. Note that formally, \b is defined as the boundary between a \w and a \W character (or vice versa), or between \w and the beginning/end of the string.
Using regex \B-\B matches - between the word color - coded . Using \b-\b on the other hand matches the - in nine-digit and pass-key .
[^ ] matches anything but a space character.
Try replacing \b
with (?:^|\s|$)
That means
( ?: don't consider this group a match ^ match beginning of line | or \s match whitespace | or $ match end of line )
Works for me in Python and JavaScript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With