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

Re: replace a string multiple times

by choroba (Cardinal)
on Nov 15, 2014 at 08:12 UTC ( [id://1107285]=note: print w/replies, xml ) Need Help??


in reply to replace a string multiple times

The quantifiers (like {3}) make sense in regular expressions. You used one in the replacement part, though, which is a pure string (and even if it worked, where would the spaces be?). There is no easy mechanism how to introduce repetition into a string, you have to call a function:
s/int/ join ' ', ('int') x 3 /ge

YMMV, but I think plain s/int/int int int/g is clearer.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-26 03:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found