While doing some small regex task I came upon this problem. I have a string that is a list of tags that looks e.g like this: foo,bar,qux,garp,wobble,thud
foo,bar,qux,garp,wobble,thud
you just need to use word boundary (\b) instead of ^ and $:
\b
^
$
\bgarp\b