Re: Adding a quantifier to substitution
- From: mohyeldin55@xxxxxxxxx
- Date: Tue, 29 Jul 2008 12:07:47 -0700 (PDT)
On Jul 29, 6:32 pm, Paul Lalli <mri...@xxxxxxxxx> wrote:
On Jul 29, 10:31 am, mohyeldi...@xxxxxxxxx wrote:
I was wondering if there is a work around to add a quantifier if I
need to replace a certain pattern with X multiples of certain
character or string like:
$str=~s/<pattern>/R{15}/g; -------> how to replace the pattern with
"R" repeated 15 times?
The /e modifier of a s/// changes the replacement from a string to a
piece of Perl code to evaluate. So use that modifier, and make your
replacement be code that returns a string comprised of 15 R's:
$str =~ s/<pattern>/'R' x 15/ge;
Paul Lalli
Thanks, that really helped.
.
- References:
- Adding a quantifier to substitution
- From: mohyeldin55
- Adding a quantifier to substitution
- Prev by Date: Re: How to find ioctl.ph - is my version of perl busted?
- Next by Date: FCGI::Request
- Previous by thread: Adding a quantifier to substitution
- Next by thread: FCGI::Request
- Index(es):
Relevant Pages
|