# warning win32 doublequotes oneliner perl -e " print $1 if $ARGV[0]=~/(AAA)[^AX].+XXX/" ABBBAAACCCXXX AAA #### perl -MYAPE::Regex::Explain -e " print YAPE::Regex::Explain->new(qr/(AAA)[^AX].+XXX/)->explain(); " The regular expression: (?-imsx:(AAA)[^AX].+XXX) 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 and capture to \1: ---------------------------------------------------------------------- AAA 'AAA' ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- [^AX] any character except: 'A', 'X' ---------------------------------------------------------------------- .+ any character except \n (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- XXX 'XXX' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------