views:

11

answers:

1

I want to do preg replace in CGI. I have a string with URL like "www.example.com/data/example.cgi?name=example". I want to write a script which will replace "/data/example.cgi" from above url to "/example.php"

A: 

$string=~ s//data\/example.cgi/example.php/g

This is what i did and works fine.... You can follow this link for details http://www.regular-expressions.info/perl.html

daron
Caution: you should note that the answer has a backslash-front slash combo. On my screen it looks like an upper case V, and I was wondering why you would add a V? Maybe I am the only one that dumb, but I thought I'd point it out, just in case.
MJB