複数の誤りがあると思います。
まずgauさんが指摘されているpngは'png'ではないのか?ということ。
そしてreplaceが意味不明(おそらくそこでもエラーが出ているはず)。
やりたいのはa2とa3というクラスの追加ですか?
それならこうなります。
JQuery
1$(".a1").each(function(){
2 if ($(this).html().match('png')) {
3 $(this).addClass("a2 a3");
4 }
5});
追記
「a1というクラスを持つ要素のhref属性内にpngという文字列が含まれていたらa2とa3というクラスを削除する」のならこうです。
$(".a1").each(function(){
if ($(this).attr('href').match('png')) {
$(this).removeClass("a2 a3");
}
});
質問の編集を受けてさらに追記
「a1というクラスを持つ要素のhref属性内にpngという文字列が含まれていたら
a2というクラスとa3というクラスを両方持っている要素を非表示にする」
$(".a1").each(function(){
if ($(this).attr('href').match('png')) {
$(".a2"+".a3").hide();
}
});