in reply to Re: commenting regular expressions?
in thread commenting regular expressions?

I had played with the following to no avail:
#!/usr/bin/perl my $s = "blah,blah,blah <PgfTag `Normal \(T\)'> yadda,yadda,yadda"; print "s =\t\"$s\"\n"; my $pattern = qr{ \s* <PgfTag `Normal \(T\)'> \s* }; my $k = 0; $s =~ s/$pattern/++$k && ','/gex; print "$k change(s)\n"; print "s =\t\"$s\"\n";

Replies are listed 'Best First'.
Re: commenting regular expressions?
by Anonymous Monk on Sep 04, 2003 at 18:22 UTC
    You have to put /x on the expression when you declare it. Also, as said, escape the literal spaces in the tags, or use \s if you don't mind matching any whitespace.
    my $pattern = qr{ <PgfTag\ `Normal\ \(T\)'> \s* \n \s* <ParaLine \s* \n \s* <String\ `$oldLabel'> \s* \n }x;
      Thanks! I had overlooked the spaces within the strings to be matched. That was it!