0

I'm modifying a php page that has messages.

Message is like

Welcome to our page bla bla bla <a href="link.php">Link content</a>

I need to replace Link content with

<img src="constant.png"/>

How do I do that?

PS. Do u know any good tutorials about regular expressions?

thanks

Jacek Pietal
  • 1,980
  • 1
  • 18
  • 27

1 Answers1

0

Assuming that there is no other tags enclosing "Link content", you can do this in bash:

sed -r 's@<a href="[^"]+">[^<]*</a>@<img src="constant.png"/>@g'

or even better if you don't need to access the value in the attribute href:

sed -r 's@<a[^>]*>[^<]*</a>@<img src="constant.png"/>@g'
justhalf
  • 8,960
  • 3
  • 47
  • 74