Using regular expressions to remove relative path slashes
        Posted  
        
            by Adam Carlile
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Adam Carlile
        
        
        
        Published on 2010-03-31T13:49:30Z
        Indexed on 
            2010/03/31
            13:53 UTC
        
        
        Read the original article
        Hit count: 645
        
Hey Guys
I am trying to remove all the relative image path slashes from a chunk of HTML that contains several other elements.
For example
<img src="../../../../images/upload/1/test.jpg />
would need to become
<img src="http://s3.amazonaws.com/website/images/upload/1/test.jpg" />
I was thinking of writing this as a rails helper, and just passing the entire block into the method, and make using Nokogiri or Hpricot to parse the HTML instead, but I don't really know.
Any help would be great
Cheers Adam
© Stack Overflow or respective owner