in reply to Multiple Match (Sort of AND)

Take your AND out of your regex; use it to connect multiple regexen.

Replies are listed 'Best First'.
Re^2: Multiple Match (Sort of AND)
by JavaFan (Canon) on Apr 25, 2010 at 23:37 UTC
    Please note that /(PAT1.*PAT2)|(PAT2.*PAT1)/ and /PAT1/ and /PAT2/ are not equivalent. The latter will match if PAT1 and PAT2 can overlap, while the former will only match non-overlapping patterns. For instance,
    $_ = "foof"; /(foo.*oof)|(oof.*foo)/;
    doesn't match, but
    $_ = "foof"; /foo/ and /oof/
    does.

    Note also that using multiple regexes cannot always be done. Think functions taking regexes are argument (split!), or patterns stored in configuration files.