|
ichiyさん,
題意を正確に理解しているかどうかわかりませんが,以下の2つのマクロで試
してください。
No.1 はあまり大きなファイルには向かないかも知れません。
No.2 はタグ内容が空白の時に列がそろいにくいかも知れません。
では, (^^)/~
山紫水明
SANSHISUIMEI
//No.1-------------------------------------------------------//
#handle = hidemaruhandle(0);
$file = filename;
disabledraw;
replaceallfast "\\n" , "", regular;//改行いったすべて削除
gofileend;
#i = 1;
while( 1 ) {
searchup "(?<=<リスト番号>)[0-9]+(?=</リスト番号>)", regular;
if( !result ) break;
$s = gettext( foundtopx, foundtopy, foundendx, foundendy );
#bx = foundtopx; #by = foundtopy;
call Search "名前";
$s = $s + "\t\t" + $$return;
call Search "電話番号";
$s = $s + "\t" + $$return;
call Search "コメント";
$s = $s + "\t" + $$return;
call Search "備考";
$s[#i] = $s + "\t" + $$return;
moveto #bx, #by;
deleteafter;
#i = #i + 1;
}
openfile "/h";
insert "リスト番号\t名前\t電話番号\tコメント\t備考";
while( #i ) {
insert $s[#i] + "\n";
#i = #i - 1;
}
replaceallfast "\\t+$" , "", regular;//行末タブ削除
showwindow 1;
#handle2 = hidemaruhandle(0);
closehidemaruforced #handle;
openfile $file;
setactivehidemaru #handle2;
endmacro;
Search:
searchdown "(?<=<" + $$1 + ">).+(?=</" + $$1 + ">)", regular;
if( result ) {
$$s = gettext( foundtopx, foundtopy, foundendx, foundendy );
}
if( $$s == "" ) $$s = "\t";
return $$s;
//-------------------------------------------------------//
//No.2-------------------------------------------------------//
selectall;
copy;
openfile "/h";
paste;
replaceallfast "[^>]\\f\\n" , "\\0", regular;//タグ以外の改行削除
replaceallfast "^[ \t]+" , "", regular;//行頭空白削除
replaceallfast "^[^<].+\\n" , "", regular;//タグ以外の行削除
replaceallfast "^<[^リ名電コ備].+\\n" , "", regular;
replaceallfast "(<リスト番号>)(.*)(</リスト番号>\\n)" , "\\2\t\t", regular;
replaceallfast "(<名前>)(.*)(</名前>\\n)" , "\\2\t", regular;
replaceallfast "(<電話番号>)(.*)(</電話番号>\\n)" , "\\2\\t", regular;
replaceallfast "(<コメント>)(.*)(</コメント>)" , "\\2\\t", regular;
replaceallfast "(\\n<備考>)(.*)(</備考>)" , "\\2", regular;
replaceallfast "\\t+$" , "", regular;//行末タブ削除
gofiletop;
insert "リスト番号\t名前\t電話番号\tコメント\t備考\n";
endmacro;
//-------------------------------------------------------//
|
|