
martygilbert
New User
Jun 30, 2008, 12:36 PM
Post #1 of 5
(8691 views)
|
Simple RegEx Help! Please!
|
Can't Post
|
|
Hi there! I'm going through a bunch of web content, and need to make all of the links relative, rather than hard-coded because I'm generating an archive to put on disk. So, instead of the link being to "/images/pic1.jpg", I want it to be "images/pic1.jpg". I have the code ready to add before the "images" directory to make it relative. It stores the number of "../" in a variable called $path. For some reason, though, my regex doesn't work! Basically, I want to replace anything like: = "/anything" with = "$path/anything" Currently, I have the following:
if(/\=\s*\"\/.*/i){ s/\=\s*\"\/(.*)/\=\"$path$1/ig; } I've never claimed to be a RegEx pro, but I usually hack one up when I need it with great success....This one, I'm afraid, never works like I think it should! Any help would be greatly appreciated! --MartyGilbert
(This post was edited by martygilbert on Jun 30, 2008, 12:44 PM)
|