RegExp Question

Discussion in 'Perl' started by Mark Friedgan, Jan 6, 2004.

  1. I would like to make a small script to do the following.

    replace a / with a - in the following situation
    it is between a []
    and not following a ://

    so [bob/susan] becomes [bob-susan]

    but [http://server/directory/file.html] stays the same

    Any helps is greatly appreciated.
    Mark Friedgan, Jan 6, 2004
    #1
    1. Advertising

  2. Mark Friedgan wrote:
    > I would like to make a small script to do the following.
    >
    > replace a / with a - in the following situation
    > it is between a []
    > and not following a ://
    >
    > so [bob/susan] becomes [bob-susan]
    >
    > but [http://server/directory/file.html] stays the same


    s{(\[[^\]]*://[^\]]*\])|(\[[^\]]+])}{
    if ($1) { $1 } else { (my $tmp = $2) =~ tr!/!-!; $tmp }
    }eg;

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Jan 6, 2004
    #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. Greg Hurrell
    Replies:
    4
    Views:
    157
    James Edward Gray II
    Feb 14, 2007
  2. Mikel Lindsaar
    Replies:
    0
    Views:
    480
    Mikel Lindsaar
    Mar 31, 2008
  3. Joao Silva
    Replies:
    16
    Views:
    355
    7stud --
    Aug 21, 2009
  4. Uldis  Bojars
    Replies:
    2
    Views:
    190
    Janwillem Borleffs
    Dec 17, 2006
  5. Matìj Cepl

    new RegExp().test() or just RegExp().test()

    Matìj Cepl, Nov 24, 2009, in forum: Javascript
    Replies:
    3
    Views:
    177
    Matěj Cepl
    Nov 24, 2009
Loading...

Share This Page