Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Modifying muliple matched strings in text

by LanX (Sage)
on Jul 12, 2020 at 13:00 UTC ( #11119208=note: print w/replies, xml ) Need Help??


in reply to Modifying muliple matched strings in text

Hint:

Call a function in the substitution part (activated by /e modifier) which returns your transformation.

s/PATTERN/replace($1,$2)/eg

Not sure if you even need to pass the matchgroups $1,... into the sub, but it's certainly more readable.

Edit

Pattern should match the links [$1]($2) (pseudo syntax).

I recommend using the /x flag for readability.

The transformations of $2 should happen inside the replace() sub

HTH!

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Modifying muliple matched strings in text
by nysus (Parson) on Jul 14, 2020 at 13:24 UTC

    Very cool. Didn't know that was even possible (well probably read about it once and then forgot). Thanks.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2021-12-09 04:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (36 votes). Check out past polls.

    Notices?