Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > RegExp Question

Reply
Thread Tools

RegExp Question

 
 
Mark Friedgan
Guest
Posts: n/a
 
      01-06-2004
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.
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      01-06-2004
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
new RegExp().test() or just RegExp().test() Matěj Cepl Javascript 3 11-24-2009 02:41 PM
[regexp] How to convert string "/regexp/i" to /regexp/i - ? Joao Silva Ruby 16 08-21-2009 05:52 PM
Ruby 1.9 - ArgumentError: incompatible encoding regexp match(US-ASCII regexp with ISO-2022-JP string) Mikel Lindsaar Ruby 0 03-31-2008 10:27 AM
Programmatically turning a Regexp into an anchored Regexp Greg Hurrell Ruby 4 02-14-2007 06:56 PM
RegExp.exec() returns null when there is a match - a JavaScript RegExp bug? Uldis Bojars Javascript 2 12-17-2006 09:59 PM



Advertisments