How do I perform multiple replacements with Perl?
Posted
by duenguyen
on Stack Overflow
See other posts from Stack Overflow
or by duenguyen
Published on 2010-05-05T00:38:02Z
Indexed on
2010/05/05
18:38 UTC
Read the original article
Hit count: 168
I have Perl code:
my $s = "The+quick+brown+fox+jumps+over+the+lazy+dog+that+is+my+dog";
I want to replace every +
with space and dog
with cat
.
I have this regular expression:
$s =~ s/\+(.*)dog/ ${1}cat/g;
But, it only matches the first occurrence of +
and last dog
.
© Stack Overflow or respective owner