Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: capture global substituion inot an array

by wrinkles (Monk)
on Apr 29, 2012 at 17:39 UTC ( #967955=note: print w/ replies, xml ) Need Help??


in reply to Re: capture global substituion inot an array
in thread capture global substitution in an array

Yes, I suspected that the real problem lies in my misunderstanding. I imagined that there is a mythical "replace" string that substitutes for the matched string. The "replace" of a regex replace is the entire resulting string, and not some discrete "diff" element. Thanks for helping me understand that better.

Perhaps what I am really looking to do (although it may be ill-conceived) is:

  • Capture the array of matched substrings based on the first modifier argument
  • loop through the array, performing a regex substitution on each substring based on the second argument.
  • return the list of modified substrings

This algorithm is certainly not a standard "regex substitution". I'll have to think more about this to determine if it even makes sense to do. But at least you have helped me define the problem. Thanks!


Comment on Re^2: capture global substituion inot an array
Re^3: capture global substituion inot an array
by ww (Bishop) on Apr 29, 2012 at 17:45 UTC
Re^3: capture global substituion inot an array
by wrinkles (Monk) on Apr 29, 2012 at 17:50 UTC
    So now I'm thinking that the tag modifier needs three arguments:
    • The match regex expression to extract the substrings.
    • The substitution regex to perform on these captured substrings.
    • The replace expression.
    Is that as crazy as it sounds to me? :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-07-28 12:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (197 votes), past polls