|
秀丸担当さん
正規表現を利用した HTML ソースの置換をテストしています.それがうまくいけば,
マクロで grepreplace を使い複数ファイルを一括処理するという目論見です.
対象ソース:
<div id="index">
<table>
<tr>
<td class="thumbcell"><a href="photo1.html"><img src="photo1.jpg" title="dum
myString1" alt="photo1.jpg" /></a></td>
<td class="thumbcell"><a href="photo2.html"><img src="photo2.jpg" title="dum
myString2" alt="photo2.jpg" /></a></td>
<td class="thumbcell"><a href="photo3.html"><img src="photo3.jpg" title="dum
myString3" alt="photo3.jpg" /></a></td>
<td class="thumbcell"><a href="photo4.html"><img src="photo4.jpg" title="dum
myString4" alt="photo4.jpg" /></a></td>
<td class="thumbcell"><a href="photo5.html"><img src="photo5.jpg" title="dum
myString5" alt="photo5.jpg" /></a></td>
</tr>
<tr>
<td colspan="5"><div class="pages">Page:[1] <a href="index2.html" title="Jum
p to index page 2">[2]</a></div></td>
</tr>
</table>
</div>
検索文字列:<table>\n([\s\S]*)(<tr>\n<td colspan=[\s\S]*</td>\n</tr>)\n</table>
置換文字列:<table>\n\2\1\n</table>
これで二つの <tr></tr> タグの順番を入れ替えられるはずですが,検索文字列がマ
ッチせず,うまくいきません.
もちろん,このソースと検索文字列によるグループキャプチャは,正規表現のチェッ
クツール(例えば https://regex101.com/)で意図通りの結果が出ることを確認して
います.
なぜうまくいかないのか...秀丸エディタで正規表現を使う経験に乏しいため,な
にか勘違いしているか,理解が及んでいないのだと思いますが,理由と対処法が分か
らず途方に暮れています.
よろしくお願いいたします.
|
|