How to remove string inside html tag <a>

Does anybody know how i can remove string from <a> tag?
There are several hundred posts in a few forums that need to be cleaned up.
The precise situation is
----------

<a href="http://mydomain.com/cgi-bin/anyboard.cgi?fvp=/family/sexuality_and_spirituality/&cmd=rA&cG=43">

-------------

my goal is to end up with clean tag <a>.

<a href="http://mydomain.com/cgi-bin/anyboard.cgi?fvp

is what never changes in the strings.

Your help is greatly appreciated.

What is the output you are expecting from the sample input?

just <a> as output every time?

yes. just <a> every time

 
sed 's/\(.*\)<a href.*>\(.*\)/\1\2/' input_file
1 Like

thank you for your time.

here are some more details

each line with the string i want to remove looks like this:

<td bgcolor="#eeeeee"><b><a href="http://mydomain/cgi-bin/anyboard.cgi?fvp=/family/sexuality\_and_spirituality/&cmd=rA&cG=44">anchor text</a></b> </td>

your code deleted the anchor text and tags around and left only

<td bgcolor="#eeeeee"></td>

maybe it is not possible with sed to clear only container <a>.

any other ideas are welcome

sed -e 's/<a href[^>]*>//g' -e 's/<\/a>//' input_file
1 Like
sed -e 's/<a href[^>]*>//g' -e 's/<\/a>//' input_file

this works like a charm.

now, would please tell me how to execute your command in safe way for all few hundred files and actually replace the string in there.