in reply to questions of a perl beginner on regex

Hi jithoosin, take a look at perlre. '?:' does not store the content in the memory. '?' is optional (either present or not) of the preceding content. To match normal '?', special character '?' has to be escaped by backslash '\?'. Here is explanation for that.

use YAPE::Regex::Explain; $REx = 'm/\.swf(?:\?.*)?$/oi'; my $exp = YAPE::Regex::Explain->new($REx)->explain; print $exp; output: ------- The regular expression: (?-imsx:m/\.swf(?:\?.*)?$/oi) 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): ---------------------------------------------------------------------- m/ 'm/' ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- swf 'swf' ---------------------------------------------------------------------- (?: group, but do not capture (optional (matching the most amount possible)): ---------------------------------------------------------------------- \? '?' ---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- )? end of grouping ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- /oi '/oi' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

Prasad