Tutorial by Examples

\bfoo\b will match the complete word with no alphanumeric and _ preceding or following by it. Taking from regularexpression.info There are three different positions that qualify as word boundaries: Before the first character in the string, if the first character is a word character. After...
Examine the following strings: foobarfoo bar foobar barfoo the regular expression bar will match all four strings, \bbar\b will only match the 2nd, bar\b will be able to match the 2nd and 3rd strings, and \bbar will match the 2nd and 4th strings.
The \b metacharacter To make it easier to find whole words, we can use the metacharacter \b. It marks the beginning and the end of an alphanumeric sequence*. Also, since it only serves to mark this locations, it actually matches no character on its own. *: It is common to call an alphanumeric sequ...
To make long text at most N characters long but leave last word intact, use .{0,N}\b pattern: ^(.{0,N})\b.*

Page 1 of 1