데모 - http://demo.widgets.co.kr/?c=64/81/82
매뉴얼 - http://kr2.php.net/manual/kr/function.preg-replace.php
iframe 제거
$STRING=preg_replace("!<iframe(.*?)<\/iframe>!is","",$STRING);
script 제거
$STRING=preg_replace("!<script(.*?)<\/script>!is","",$STRING);
meta 제거
$STRING=preg_replace("!<meta(.*?)>!is","",$STRING);
style 태그 제거
$STRING=preg_replace("!<style(.*?)<\/style>!is","",$STRING);
를 공백으로 변환
$STRING=str_replace(" "," ",$STRING);
연속된 공백 1개로
$STRING=preg_replace("/\s{2,}/"," ",$STRING);
태그안에 style= 속성 제거
$STRING=preg_replace("/ style=([^\"\']+) /"," ",$STRING); // style=border:0... 따옴표가 없을때
$STRING=preg_replace("/ style=(\"|\')?([^\"\']+)(\"|\')?/","",$STRING); // style="border:0..." 따옴표 있을때
태그안의 width=, height= 속성 제거
$STRING=preg_replace("/ width=(\"|\')?\d+(\"|\')?/","",$STRING);
$STRING=preg_replace("/ height=(\"|\')?\d+(\"|\')?/","",$STRING);
img 태그 추출 src 추출
preg_match("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i",$STRING,$RESULT);
preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i",$STRING,$RESULT);
호스트 추출
preg_match("/^(http:\/\/)?([^\/]+)/i","http://www.naver.com/index.html",$matches);
$host = $matches[2];
echo$matches[0]."<br>";
echo$matches[1]."<br>";
echo$matches[2]."<br>";
출력 -
http://www.naver.com
http://
www.naver.com
데모 - http://demo.widgets.co.kr/?c=64/81/82
게시글 목록
| 번호 | 제목 |
|---|---|
| 18088 | |
| 18080 | |
| 18078 |
JavaScript
document.querySelector 의 상수화
2
|
| 18070 |
JavaScript
로또데이터 자바스크립트 기본함수
7
|
| 18061 | |
| 18037 |
JavaScript
당첨확률 높은 로또번호 추출하기
24
|
| 18036 | |
| 18033 | |
| 18022 | |
| 18021 | |
| 18020 | |
| 18018 | |
| 18004 | |
| 17999 | |
| 17995 | |
| 17987 |
PHP
메일 사진 첨부하는 방법
2
|
| 17982 | |
| 17981 |
OS
오래된 파일 지우기
|
| 17980 |
기타
링크 단축기
|
| 17970 | |
| 17965 | |
| 17964 | |
| 17963 |
JavaScript
마우스 아웃시 레이어창이 안닫혀요
|
| 17962 | |
| 17960 |
jQuery
카카오 우편번호 jquery로 변환
|
| 17956 |
PHP
계좌번호 복사소스
1
|
| 17953 |
Mobile
br 태그 모바일에만 보여주기
|
| 17949 | |
| 17930 | |
| 17928 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기