HTMLコードを作成するとき、すべてのタグを削除する必要がある場合があります。タグを1つずつ削除するのは面倒です。迅速で便利な方法はありますか? HTMLコードのすべてのタグを削除する方法を見てみましょう。
HTMLコードのすべてのタグを削除します
コードコピーは次のとおりです。<%
'*******************************
'関数:removehtml_a(strtext)
'引数:strtext、処理される文字列
著者:アリクシ
'日付:2007/7/12
'説明:HTMLコードのすべてのタグを削除します
'例:<%= removehtml_a( "<b> Alixixiへようこそ</b>")%>
'*******************************
関数removehtml_a(strtext)
dim npos1
dim npos2
npos1 = strtext、 "<")
NPOS1> 0を実行します
npos2 = strust(npos1+1、strtext、 ">")
npos2> 0の場合
strtext = left(strtext、npos1-1)&mid(strtext、npos2 + 1)
それ以外
終了します
ifを終了します
npos1 = strtext、 "<")
ループ
removehtml_a = strtext
エンド関数
%>
HTMLコードのすべてのタグを削除します
コードコピーは次のとおりです。<%
'*******************************
'関数:removehtml_b(strtext)
'引数:strtext、処理される文字列
著者:アリクシ
'日付:2007/7/12
'説明:HTMLコードのすべてのタグを削除します
'例:<%= removehtml_b( "<b> Alixixiへようこそ</b>")%>
'*******************************
関数removehtml_b(strtext)
薄暗いregex
regex = new regexpを設定します
regex.pattern = "<[^>]*>"
regex.global = true
removehtml_b = regex.replace(strtext、 "")
エンド関数
%>
HTMLコードのすべてのタグを削除します
コードコピーは次のとおりです。<%
'*******************************
'関数:removehtml_c(strtext)
'引数:strtext、処理される文字列
著者:アリクシ
'日付:2007/7/12
'説明:HTMLコードのすべてのタグを削除します
'例:<%= removehtml_c( "<b> Alixixiへようこそ</b>")%>
'*******************************
関数removehtml_c(strtext)
薄暗いタグリスト
TAGLIST = "; &_
「bgsound; big; blockquote; body; br; button; caption; center; cite; code;」 &_
「col; colgroup; comment; dd; del; dfn; dir; dl; dt; em; embed; fieldset;」 &_
"font; form; frame; frameset; head; h1; h2; h3; h4; h5; h6; hr; html; i; iframe; img;" &_
「入力; ins; isindex; kbd; label; layer; lagend; like; link; listing; map; marquee;」 &_
「メニュー;メタ; nobr; noframes; noscript; object; ol; option; p; param; plantext;」 &_
「pre; q; s; samp; script; select; select; small; spring; strike; strong; style; sub; sup;」 &_
「テーブル; tbody; td; textarea; tfoot; th; thead; titl; tr; tt; u; ul; var; wbr; xmp; "
const blocktaglist = "; appet; embred; frameset; head; noframes; noscript; object; script; style;"
dim npos1
dim npos2
dim npos3
薄暗いストレルト
dim strtagname
薄暗いブレーブ
dim bsearchforblock
npos1 = strtext、 "<")
NPOS1> 0を実行します
npos2 = strust(npos1 + 1、strtext、 ">")
npos2> 0の場合
strtagname = mid(strtext、npos1 + 1、npos2 -npos1-1)
strtagname = cheplace(leplage(strtagname、vbcr、 "")、vblf "")
npos3 = strut(strtagname、 "")
npos3> 0の場合
strtagname = left(strtagname、npos3-1)
ifを終了します
残っている場合(strtagname、1)= "/" then
strtagname = mid(strtagname、2)
bsearchforblock = false
それ以外
bsearchforblock = true
ifを終了します
If strust(1、 ";"&strtagname& ";"、vbtextcompare)> 0
bremove = true
bsearchforblockの場合
If strust(1、blocktaglist、 ";"&strtagname& ";"、vbtextcompare)> 0
npos2 = len(strtext)
npos3 = strust(npos1 + 1、strtext、 "</"&strtagname、vbtextcompare)
npos3> 0の場合
npos3 = strust(npos3 + 1、strtext、 ">")
ifを終了します
npos3> 0の場合
npos2 = npos3
ifを終了します
ifを終了します
ifを終了します
それ以外
bremove = false
ifを終了します
Bremoveの場合
strenutult = strensult&left(strtext、npos1-1)
strtext = mid(strtext、npos2 + 1)
それ以外
strErult = strErult&left(strtext、npos1)
strtext = mid(strtext、npos1 + 1)
ifを終了します
それ以外
strenult = stresult&strtext
strtext = ""
ifを終了します
npos1 = strtext、 "<")
ループ
strenult = stresult&strtext
removehtml_c = stresult
エンド関数
%>
これは、HTMLコードのすべてのタグを削除することです。誰もが特定の理解を持っていると思います。より多くの技術情報を知りたい場合は、間違った新しいテクノロジーチャネルに注意を払い続けてください!