in reply to Cleaner regex conversion

How about giving us an example of what you want to do?

In the mean time, here's a stab at what I think you mean:

my $lines = "} } \n } }\n foo } }\n"; $lines =~ s,(}[}\s]*)\n, "}\n" x ($1 =~ tr!}!!) ,xgem; print $lines; __END__ } } } } foo } }

Replies are listed 'Best First'.
Re^2: Cleaner regex conversion
by DanielNeedles (Novice) on Jul 05, 2008 at 13:11 UTC
    This is perfect. I haven't seen the format before this:

    s/()/"." x ()/ge

    Is there a URL or book that covers these more advanced regexp?

      Well, the official perl book is 'Programming Perl' (Wall,Christiansen,Schwartz) and it naturally has this and practically everything else covered.

      Also check out the manual pages, in this case perlre (also available online: http://perldoc.perl.org/perlre.html ).

        Hmm. I have a copy of that book but it is several years old. I also checked the perlre and didn't find reference to the use of 'x' in the replace portion of the expression:

        s/()/"." x ()/ge

        Can you give me a more specific reference? I've looked but do not see it.

        Thanks. Nevermind the last comment. I found it under Multiplicative Operators in the web link you provided.