정규식 각종 태그 제거 샘플

 

//iframe 제거
preg_replace("!!is","",$STRING)

//script 제거
preg_replace("!!is","",$STRING)

//meta 제거
preg_replace("!!is","",$STRING)

//style 태그 제거
preg_replace("!!is","",$STRING)

// 를 공백으로 변환
str_replace(" "," ",$STRING)

//연속된 공백 1개로
preg_replace("/s{2,}/"," ",$STRING)

//style= 속성 제거
preg_replace("/ style=([^"'] ) /"," ",$STRING)

// style=border:0... 따옴표가 없을때
preg_replace("/ style=("|')?([^"'] )("|')?/","",$STRING)

//태그안의 width=, height= 속성 제거preg_replace("/ width=("|')?d ("|')?/","",$STRING)
preg_replace("/ height=("|')?d ("|')?/","",$STRING)

//img 태그 추출 src 추출
preg_match("/]*src=["']?([^>"'] )["']?[^>]*>/i",$STRING,$RESULT)
preg_match_all("/]*src=["']?([^>"'] )["']?[^>]*>/i",$STRING,$RESULT)

 

Press ESC to close