in reply to Re: Regex matching a string beginning with "root: " but not containing another string
in thread Regex matching a string beginning with "root: " but not containing another string

Here's a little sub to generate such a regex from the string you want not to match:
sub not_string_regex { my $str = shift; my $reg; for(0..length($str)-1) { my $let = substr($str,$_,1); $reg .= '($|[^'.$let.']|'.$let; } substr($reg, -2) = ''; $reg .= ')' x length($str); }

Caution: Contents may have been coded under pressure.
  • Comment on Re^2: Regex matching a string beginning with "root: " but not containing another string
  • Download Code