[prog] Perl regex

Dan Richter daniel.richter at wimba.com
Fri May 9 12:16:29 EST 2003


Hi everyone.

I'm writing a Perl program that includes this line of code:

if ( $html =~ m!<div><script>.{0,10}\s*
     function\s+Filtered.{0,10}[{]\s*return\s+0.{0,5}[}]\s*.{0,20}
     </script>(.*?)<font color=\#000000></div>!si ) {

(I put it on several lines for legibility, but it's all one line in the 
program, with no space characters in the regular expression.)

I want to use the "/x" modifier (it would be "!x" in this case) to split 
the regular expression onto several lines for readability. However, when I 
add the "x", the regular expression fails to match against a test case that 
it matched previously, even before I split it onto several lines.

I've already noticed the "#" near the end (<font color=#000000>) and 
escaped it. (I've also tried putting it in [].) I have ruled that out as a 
source of the problem. Does anyone have any idea what the problem is?

========== Dan Richter ============== mailto:Dan at wimba.com ===========
  Their reproof adds the / injury of insult to / the shame of failure.
       - Damian Conway, whose Perl script transforms computer
         error messages into haikus.



More information about the Programming mailing list