htmlの中の大量にある画像でjpg以外のimgタグを検索したり
htmlで終わらないaタグやtarget属性のないaタグだけを検索したりしたくなりませんか?
なるんですよ。なったんですよ。
でDreamweaverの正規表現でサクっと出来んもんかな?と頭をひねってみました。
否定先読みってのを使うと出来るっぽいです。
jpg以外のimgタグを検索
検索対象
[html]
<img src="example.jpg" alt="" />
<img src="example.jpg" alt="" />
<img src="example.png" alt="" />
<img src="example.jpg" alt="" />
<img src="example.png" alt="" />
<img src="example.gif" alt="" />
[/html]
検索文字
[text](?!src=".*jpg")src=".*"[/text]
target属性のないaタグだけを検索
検索対象
[html]
<a href="example.html" target="_blank">_blankで開け</a>
<a href="example.html" target="_blank">_blankで開け</a>
<a href="example.html">target指定なし</a>
<a href="example.html" target="_blank">_blankで開け</a>
<a href="example.html">target指定なし</a>
<a href="example.html" target="_top">_topで開け</a>
<a href="example.html">target指定なし</a>[/html]
検索文字
[text](?!<a.*target=")<a[/text]
.html以外のリンクを検索
検索対象
[html]
<a href="example.pdf" target="_blank">_blankで開け</a>
<a href="example.html" target="_blank">_blankで開け</a>
<a href="example.html">target指定なし</a>
<a href="example.htm" target="_blank">_blankで開け</a>
<a href="example/example">target指定なし</a>
<a href="/" target="_top">_topで開け</a>
<a href="example.html">target指定なし</a>
[/html]
検索文字
[text](?!href=".*html")href=".*"[/text]
ありゃ、head内のcssもマッチしちゃった。
検索 – 特定のタグ でやる
target属性を含めないaタグみたいのなら特定のタグで検索できた。
.jpgじゃないimgの検索の仕方は分からなかった、出来るのかな?
コメント