わかりました、divに次のデータがあります
<div id="mydiv">
<!--
what is your present
<code>alert("this is my present");</code>
where?
<code>alert("here at my left hand");</code>
oh thank you! i love you!! hehe
<code>alert("welcome my honey ^^");</code>
-->
</div>
私がそこでしなければならないことは、内部<code>
の HTML コメントを削除せずに、ブロック内のすべてのスクリプトと HTML コード テキスト ノードを取得することです。それは私の教授から与えられた宿題であり、そのdivブロックを変更することはできません..
これには正規表現を使用する必要があり、これが私がしたことです
var block = $.trim($("div#mydiv").html()).replace("<!--","").replace("-->","");
var htmlRegex = new RegExp(""); //I don't know what to do here
var codeRegex = new RegExp("^<code(*n)</code>$","igm");
var code = codeRegex.exec(block);
var html = "";
それは本当にうまくいきません...正確な答えを出さないでください..教えてください..ありがとう
変数には次のブロックが必要ですcode
alert("this is my present");
alert("here at my left hand");
alert("welcome my honey ^^");
これは変数に必要なブロックですhtml
what is your present
where?
oh thank you! i love you!! hehe
私の質問は、上記の結果を得るための正規表現パターンは何ですか?