Multiple substitutions with Regexp::Common?

A

Adam

I've searched the web and the Regexp::Common docs and testsuite but
can't figure out how to do multiple substitutions (assuming it's
possible). Obviously, in a normal Perl sub, I can do this:

$var =~ s/foo/blah/g;

I'm running Regexp::Common as such:

$msg = $RE{URI}{HTTP}{-scheme => "https?"}{-keep}->subs($msg =>
"XXX");

(I'm just playing around at the moment, hence the change to "XXX")

Any way to substitute ALL occurrences as the 'g' parameter does?
Thanks for any information.
 
P

Paul Lalli

I've searched the web and the Regexp::Common docs and testsuite but
can't figure out how to do multiple substitutions (assuming it's
possible). Obviously, in a normal Perl sub, I can do this:

$var =~ s/foo/blah/g;

I'm running Regexp::Common as such:

$msg = $RE{URI}{HTTP}{-scheme => "https?"}{-keep}->subs($msg =>
"XXX");

(I'm just playing around at the moment, hence the change to "XXX")

Any way to substitute ALL occurrences as the 'g' parameter does?
Thanks for any information.

This may be a stupid question, but why not just use the normal syntax
rather than OOP?

$msg =~ s/$RE{URI}{HTTP}{-scheme=>"https?"}{-keep}/XXX/g;

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top