DanielNeedles has asked for the wisdom of the Perl Monks concerning the following question:
Is there a cleaner way via a regex to recurse through a series of '}' at the end of a line and insert newlines?
Specifically can:Get replaced by a single line of regex that recurses through text that contains many instances of /}+$/ and convert each '}' to \n}my $bracketend = 8 * $lines =~ s/\}\s*\}\s*\}\s*\}\s*\}<\s*\}\s*\}\s*\ +}$/\n\}\n\}\n\}\n\}\n\}\n\}\n\}\n\}/gms; $bracketend += 4 * $lines =~ s/\}\s*\}\s*\}\s*\}$/\n\}\n\}\n\}\n\}/gms +; $bracketend += 2 * $lines =~ s/\}\s*\}$/\n\}\n\}/gms; $bracketend += $lines =~ s/\}$/\n\}/gms;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Cleaner regex conversion
by pc88mxer (Vicar) on Jul 05, 2008 at 06:54 UTC | |
by DanielNeedles (Novice) on Jul 05, 2008 at 13:11 UTC | |
by jethro (Monsignor) on Jul 05, 2008 at 13:59 UTC | |
by Anonymous Monk on Jul 05, 2008 at 17:19 UTC | |
by linuxer (Curate) on Jul 05, 2008 at 22:12 UTC | |
by Anonymous Monk on Jul 05, 2008 at 17:26 UTC | |
by jethro (Monsignor) on Jul 05, 2008 at 22:09 UTC |