Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^5: Replace newlines only if not inside braces

by trizen (Hermit)
on Feb 11, 2013 at 21:47 UTC ( #1018249=note: print w/replies, xml ) Need Help??


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

Nope. It doesn't matter. The group doesn't match a single newline, so it can be greedy. It will try to match either the brackets block or any other character which is not a newline. If it succeeds, then tries again to match the block or a non-newline character. If it fails, it will match the newline character (\n) and makes the replace.

Using the non-greedy quantifier, will do the same thing, but a little bit slower because it needs, unnecessary, to look ahead after each repetition (theoretically).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018249]
help
Chatterbox?
[stevieb]: I have got ready everything in a stable manner to go forward with a full-blown "Raspberry Pi with Perl" series, and at the same time "Automated testing locally for everything" series. A year it took. A year I've been waiting to do this.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2017-06-29 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (653 votes). Check out past polls.