javascript ÀÚ¹Ù½ºÅ©¸³Æ® html ÅÂ±× Á¦°Å |
|
|
 |
10³â Àü |
javascript ÀÚ¹Ù½ºÅ©¸³Æ® Á¤±Ô½Ä replace html Á¦°Å ÅÂ±× Á¦°Å
³»°¡ ¾Æ´Â ÀÚ¹Ù½ºÅ©¸³Æ®·Î html Á¦°ÅÇÏ´Â Á¤±Ô½Ä Áß¿¡ °¡Àå °·ÂÇÏ´Ù¤»¤»
Á¤±Ô½ÄÀ» ¿ÏÀüÈ÷ ¾ËÁö ¸øÇØ Áߺ¹ÀÎ °Íµµ ÀÖ°ÚÁö¸¸ Àß Áö¿öÁø´Ù
/**
* Áö½Ä³»¿ëÀÇ HTMLÀ» Á¦°ÅÇÑ´Ù.
*/
function removeHtml(text)
{
text = text.replace(/<br>/ig, "\n"); // <br>À» ¿£ÅÍ·Î º¯°æ
text = text.replace(/ /ig, " "); // °ø¹é
// HTML ű×Á¦°Å
text = text.replace(/<(\/)?([a-zA-Z]*)(\s[a-zA-Z]*=[^>]*)?(\s)*(\/)?>/ig, "");
// shkim.add.
text = text.replace(/<(no)?script[^>]*>.*?<\/(no)?script>/ig, "");
text = text.replace(/<style[^>]*>.*<\/style>/ig, "");
text = text.replace(/<(\"[^\"]*\"|\'[^\']*\'|[^\'\">])*>/ig, "");
text = text.replace(/<\\w+\\s+[^<]*\\s*>/ig, "");
text = text.replace(/&[^;]+;/ig, "");
text = text.replace(/\\s\\s+/ig, "");
return text;
}
|
|
̵̧ : 503 |
̵̧
¸ñ·Ï
|
|