Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: RegExp: pos management in global substitution

by Anonymous Monk
on Sep 03, 2011 at 12:59 UTC ( #923988=note: print w/ replies, xml ) Need Help??


in reply to RegExp: pos management in global substitution

Can this be done with s/// operator without e modifier in one approach?

Probably, but its a brainfuckadvanced way to go about it :)

1. After success substitution return to the position where substitution started and try to substitute again...

Not sure , but I don't think you can without /e

Here is my non working advanced attempt

s{ (?<= \{name_a ) (?: (?: (?<= \s ) | (?<= param_[xy]=" ) (?: (?<= [^"] ) )+ (?<= " ) ) | param_[^xy]\w*="[^"]+" )+ (?<= \} ) }< eaten >gx;
I'm probably not understanding (?<=pattern) correctly

The following works

s/ \{name_a ( (?: [^=\s]+ = "[^"]*" | \s+ )+ ) \}/ FunAt($1) /gex; sub FunAt { join '', '{name_a ', AtAt(@_) ,'}'; } sub AtAt { my %fun = $_[0] =~ m/([^=\s]+) = ("[^"]*")/gx; return join ' ', map { "$_=$fun{$_}" } grep /param_[xy]/, keys %fu +n; }


Comment on Re: RegExp: pos management in global substitution
Select or Download Code
Re^2: RegExp: pos management in global substitution
by OlegG (Monk) on Sep 03, 2011 at 17:49 UTC
    This solution is not interesting.

      This solution is not interesting.

      I wouldn't have bothered otherwise if you had been clearer when you asked for other solutions

        I think "Can this be done with s/// operator without e modifier" is very clear. And you give me solution with e modifier. Are you kidding me? :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2014-10-24 11:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls