in reply to Re^3: regex problem solved
in thread regex problem

The regex
    (?!pattern).
simply says that whatever  . matches is not the start of whatever  pattern matches (which can be any regex whatsoever). Wrapping this in a non-capturing group
    (?:(?!pattern).)
allows you to quantify the grouped expression in the usual way, so
    (?:(?!pattern).)*?
means "zero or more of anything as long as it doesn't begin a  pattern sequence, with lazy instead of greedy matching". (And I'll go to my grave using "lazy" instead of "non-greedy" as the antonym of "greedy" matching.)

Here's what YAPE::Regex::Explain sez, but I don't think it captures the essence of the concept as clearly:

c:\@Work\Perl\monks>perl -wMstrict -le "use YAPE::Regex::Explain; ;; print YAPE::Regex::Explain->new('(?:(?!pattern).)*?')->explain; " The regular expression: (?-imsx:(?:(?!pattern).)*?) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- (?: group, but do not capture (0 or more times (matching the least amount possible)): ---------------------------------------------------------------------- (?! look ahead to see if there is not: ---------------------------------------------------------------------- pattern 'pattern' ---------------------------------------------------------------------- ) end of look-ahead ---------------------------------------------------------------------- . any character except \n ---------------------------------------------------------------------- )*? end of grouping ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------


Give a man a fish:  <%-{-{-{-<