Multiple substitutions with Regexp::Common?

Discussion in 'Perl Misc' started by Adam, May 15, 2007.

  1. Adam

    Adam Guest

    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.
     
    Adam, May 15, 2007
    #1
    1. Advertising

  2. Adam

    Paul Lalli Guest

    On May 15, 10:45 am, Adam <> wrote:
    > 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
     
    Paul Lalli, May 15, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Denny
    Replies:
    1
    Views:
    820
  2. Christopher Causer

    Multiple substitutions in one pass

    Christopher Causer, Feb 26, 2008, in forum: Ruby
    Replies:
    0
    Views:
    110
    Christopher Causer
    Feb 26, 2008
  3. Joao Silva
    Replies:
    16
    Views:
    404
    7stud --
    Aug 21, 2009
  4. kd

    Multiple Substitutions in perl

    kd, Oct 16, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    129
    Tad McClellan
    Oct 16, 2005
  5. John Reye
    Replies:
    28
    Views:
    1,415
    Tim Rentsch
    May 8, 2012
Loading...

Share This Page