in reply to commenting regular expressions?

Howdy!

Did you use the /x modifier?

I see white space in your regexes. If you use /x, you have to escape the white space or it gets ignored.

For example (untested):

qr{<PgfTag [ ] # this matches a space 'Normal \ # the backslash ought to escape the space \\(T\)'> ...
and so forth...

yours,
Michael

Replies are listed 'Best First'.
Re: Re: commenting regular expressions?
by SeekerOKnowledge (Initiate) on Sep 04, 2003 at 18:08 UTC
    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";
      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!