It will match nothing (unless the string is changed to the single word bells).
Notice that for ^bells$
to match the string bells there
must not be any spaces at the beginning or end of the string.
Regular Expression (Delimit with quotes) |
|
String (Delimit with quotes) |
|
Sometimes you want to find a word, not a substring that is part of
a larger word.
Use \b
to match a word boundary.
Usually a word boundary is whitespace (blanks, tabs, and a few other characters).
But word boundaries also include the beginnings and ends of lines,
cases which are otherwise easily overlooked when searching through a text file.
To match a non-word boundary, use \B
in the expression.
To find the substring cat that is embedded within another
word use \Bcat\B
Write a regular expression that matches complete words that begin with the prefix cat .