文字列のスクリプトタグ削除(Javascript)
タグのみ削除、空白は削除しない
function TagDelete(Text) { if (Text == "" || Text == null) return ""; //スクリプト文字 Text = Text.replace(/</g, "<");//"<"をコードに変換(タグ無効化) Text = Text.replace(/>/g, ">"); //">"をコードに変換(タグ無効化) Text = Text.replace(/(<([^>]+)>)/ig, ""); return Text; }
タグ削除、空白削除
function TagAndBlankDelete(Text) { if (Text == "" || Text == null) return ""; //スクリプト文字 Text = Text.replace(/(<([^>]+)>)/ig, ""); Text = Text.replace(/\s+/g, ""); return Text; }