Maybe now would be a good moment to look at perlre to learn about how the regular expression matching </script> works. YAPE::Regex::Explain contains the explain tool that does that:
The regular expression: (?-imsx:^<\/script>\s+-->) 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): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- < '<' ---------------------------------------------------------------------- \/ '/' ---------------------------------------------------------------------- script> 'script>' ---------------------------------------------------------------------- \s+ whitespace (\n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- --> '-->' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
... then you'll note that the regular expression only matches at the beginning of the string. Maybe you want to change that expression (and maybe the others as well) to allow for optional whitespace between the beginning of the string and the </script> tag. You would then add \s* between the "beginning of the string" anchor and the match for </script>.
In reply to Re^7: perl script to search and replace comment in .aspx file
by Corion
in thread perl script to search and replace comment in .aspx file
by hector89
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |