1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
var result,
    stripScripts;
 
stripScripts = function(value) {
 
    var pattern = /<script[^>]*>((\n|\r|.)*?)<\/script>/img;
    
    return value.replace(pattern, '');
}
 
result = stripScripts('<script type="text/javascript">var a = 123;</script>script 이외');
show(result);
 
result = stripScripts('<script></script><script></script>script 두 개 작성');
show(reuslt);
 
cs


출처 : 기본 원리를 완전 분석한 자바스크립트 정규표현식


+ Recent posts

블록 제거","entryType":"POST","categoryName":"Programming/Javascript","categoryId":"563658","serviceCategoryName":null,"serviceCategoryId":null,"author":"1313463","authorNickname":"editor2080","blogNmae":"Another Windows","image":"","plink":"/entry/scriptscript-%EB%B8%94%EB%A1%9D-%EC%A0%9C%EA%B1%B0","tags":[]},"kakaoAppKey":"3e6ddd834b023f24221217e370daed18","appUserId":"null"}