in reply to Re: regex clarification
in thread regex clarification
I like this solution, because it's an easy way to rule out lines that contain something (ie, "vet") anywhere after the first word, which is I think what the OP really wants to do.
while (<DATA>) { # match the first word # in lines that don't contain "vet" anywhere push(@array, $1) if m/^(?!\w+\b.*vet)(\w+)/i; } print("@array\n"); __DATA__ David Veterinarian Jackie Orthopedist Karen Veterinarian Vetch Orthopedist Vetch Veterinarian
|
|---|