Does Sed Search/Replace Work For Multiple Matches On The Same Line?

Hello,

I would like to delete all the footnotes in all my htm files. Hence, I have to delete the whole font tag pairs, i.e. deleting everything between the begin/end font tags.

I create a testfile, of which data parts of all four lines are the same except for the number of font tag pairs, for testing as follows.
# sed -n 'l' testfile

  1. The quick brown fox jumps over the lazy dog. -- this is correct li\
    ne<br>$
  2. The quick<FONT SIZE="1"><SUB>Footnote_1</SUB></FONT> brown fox jum\
    ps over the lazy dog. -- 1x FONT Tag Pairs<br>$
  3. The quick<FONT SIZE="1"><SUB>Footnote_1</SUB></FONT> brown fox jum\
    ps<FONT COLOR="RED"><SUB>Footnote_2</SUB></FONT> over the lazy dog. -\
  • 2x FONT Tag Pairs<br>$
  1. The quick<FONT SIZE="1"><SUB>Footnote_1</SUB></FONT> brown fox jum\
    ps<FONT COLOR="RED"><SUB>Footnote_2</SUB></FONT> over the lazy<FONT F\
    ACE="COURIER"><SUB>Footnote_3</SUB></FONT> dog. -- 3x FONT Tag Pairs<\
    br>$
    #

Then I 'sed' to remove the font tag pairs as follows.
# sed -e 's/<FONT.*<\/FONT>//g' file4

  1. The quick brown fox jumps over the lazy dog. -- this is correct line<br>
  2. The quick brown fox jumps over the lazy dog. -- 1x FONT Tag Pairs<br>
  3. The quick over the lazy dog. -- 2x FONT Tag Pairs<br>
  4. The quick dog. -- 3x FONT Tag Pairs<br>
    #

The above sed script works only for the line containing only 1x font tag pairs. It looks to me that sed only finds the longest match on the line. For the lines containing more than one font tag pairs, my sed script doesn't work. It deletes some useful data on the line. What am I missing?

Please help!!!

Thank you very much for your assistance.

Best Regards,
cibalo

Can Pls Post exactly what is your input and the output your expecting in the formatted fashion.I hope then you will get more responses.

As far as I know, sed doesn't support RE's non-greedy match ..., try a different tool that supports it:

perl -0pe 's!<FONT.*?</FONT>!!gs' file

Output:

1. The quick brown fox jumps over the lazy dog. -- this is correct line<br>
2. The quick brown fox jumps over the lazy dog. -- 1x FONT Tag Pairs<br>
3. The quick brown fox jumps over the lazy dog. -- 2x FONT Tag Pairs<br>
4. The quick brown fox jumps over the lazy dog. -- 3x FONT Tag Pairs<br>

Hello panyam, rubin!

Thank you guys for replying to my post.

Best Regards,
cibalo