RegExp Question

M

Mark Friedgan

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.
 
G

Gunnar Hjalmarsson

Mark said:
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;
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top