Sign in with
Sign up | Sign in
Your question

Substitute Syntax???

Last response: in Linux/Free BSD
Share
October 8, 2008 4:18:00 AM

Sup all..

I have a web album on my server and I am trying to take a hyperlink off all the image pages...

This is the original code..
  1. <a href="target920.html">Last</a> | <a href="index.html">Thumbnails</a> | <a href="<a href="http://germany08.myftp.org/" rel="nofollow" target="_blank">http://germany08.myftp.org/</a>">Home</a><br>
  2.  
  3. </span><hr size="1">


I am trying to take off the
  1. | <a href="<a href="http://germany08.myftp.org/" rel="nofollow" target="_blank">http://germany08.myftp.org/</a>">Home</a><br>

Portion and replace with a simple
  1. <br>
.

The command I am using is..

  1. perl -pi~ -e 's/| <a href="http:"\"/"\"/germany08.myftp.org"\"/">Home<"\"/a><br>/<br>/' target1.html


Edit: Edit: Dont mind the "" around the \ .... when I entered the \ in the code it was taking them out.. so disregard the ""'s around the \'s

When I run that code I get this as my output in the file..tons of <br> on everyline...

  1. <br><a href="target2.html">Next Picture</a> |
  2. <br>
  3. <br><a href="target920.html">Last</a> | <a href="index.html">Thumbnails</a> | <a href="<a href="http://germany08.myftp.org/" rel="nofollow" target="_blank">http://germany08.myftp.org/</a>">Home</a><br>
  4. <br>
  5. <br></span><hr size="1">
  6. <br>
  7. <br>
  8. <br>


Any ideas? As you can see its even tossing an <br> between the 2 original lines of code and its not even taking out the link...

More about : substitute syntax

October 13, 2008 6:37:57 AM

Try perl -pi -e 's/\| <a href="http:\/\/germany08.myftp.org\/">Home<\/a><br>/<br>/; ' < test.html

You have to escape | and other special chars.

Good Luck :) 
October 13, 2008 6:39:26 AM

Oh yeah, it works :) 

[user@localhost ~]$ perl -pi -e 's/\| <a href="http:\/\/germany08.myftp.org\/">Home<\/a><br>/<br>/; ' < test.html
<a href="target920.html">Last</a> | <a href="index.html">Thumbnails</a> <br>

!