You can take below as a sample test file.
$cat /tmp/file test1 ALL=ALL abc test1 ALL=ALL test1 ALL=ALL w.test1 ALL=ALL testing w.test1 ALL=ALL
Run under the regex to find the word starting with test1 and the line that also has the word test1 in it.
$ grep -E '(^|\s+)test1\b' /tmp/file test1 ALL=ALL abc test1 ALL=ALL test1 ALL=ALL
source share