Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Replace newlines only if not inside braces

by 7stud (Deacon)
on Feb 11, 2013 at 16:33 UTC ( #1018177=note: print w/ replies, xml ) Need Help??


in reply to Re: Replace newlines only if not inside braces
in thread Replace newlines only if not inside braces

Did that s/// win an obfuscation contest somewhere?

use warnings; use strict; use 5.012; my $data = <<'END_OF_TEXT'; foo bar {{ alpha beta }} baz END_OF_TEXT $data =~ s/ (?: #Non-capturing group {{.*?}} #Text enclosed by double braces \K #Exclude what's to the left of \K from match )? #Match whole group 0 or 1 time \n /\n<br>/gxms; say $data; --output:-- foo <br>bar <br>{{ alpha beta }} <br>baz <br>

It would make more sense to put the newlines after the breaks if you were trying to pretty print some html.


Comment on Re^2: Replace newlines only if not inside braces
Download Code
Replies are listed 'Best First'.
Re^3: Replace newlines only if not inside braces
by Anonymous Monk on Feb 11, 2013 at 19:20 UTC
    Did that s/// win an obfuscation contest somewhere?
    so what's your contribution?
    It would make more sense to put the newlines after the breaks if you were trying to pretty print some html.
    minor problems of minor minds...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018177]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-08-31 12:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (354 votes), past polls