Reputation: 67
How to find the line that starts with at least one dog from the following lines
-catdogcat [pass]
-dog------ [pass]
-catdoglol dog [pass]
-catcatcat dog [fail]
I wrote /^-(dog){1,3}/
but it certainly doesn't work when the input is '-catdogcat'
Upvotes: 0
Views: 39
Reputation: 36101
/^-\S*dog/
The idea is to start with a dash, followed by any amount of non-whitespace characters, followed by a dog
.
/^-(\S{3})*dog/
/^-(\S{3}){0,2}dog/
Upvotes: 1