데모 - 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
게시글 목록
| 번호 | 제목 |
|---|---|
| 17657 | |
| 17655 | |
| 17654 | |
| 17653 |
JavaScript
ThreeJS - 3D Bar and Progress Bar
1
|
| 17652 |
node.js
RAM점유크기에 의한 노드서버관리
|
| 17651 |
JavaScript
Javascript Undo, Redo 기능 구현하기
|
| 17650 | |
| 17642 |
node.js
nodejs서버가 사용중인 메모리에 대한 로그
|
| 17633 |
node.js
node.js에서 스케쥴링작성
8
|
| 17632 | |
| 17631 |
MySQL
InnoDB와 MyISAM의 우단점
|
| 17630 | |
| 17628 |
JavaScript
자바스크립트 기반으로 HTML Canvas에 이미지를 불러들여 테두리색입히기
|
| 17624 | |
| 17623 | |
| 17620 |
node.js
tcp소켓과 websocket 의 비교
2
|
| 17618 |
JavaScript
JavaScript로 이미지의 부분 영역을 따내기
|
| 17617 | |
| 17614 | |
| 17612 | |
| 17611 | |
| 17610 | |
| 17609 | |
| 17608 |
node.js
Node.js로 지속적인 핑 결과를 파일로 저장
|
| 17607 |
정규표현식
특수문자 제거, 우리글짜가 있는지 체크
|
| 17604 |
node.js
Node.js에서 PDF 파일의 페이지 수를 얻기
|
| 17603 | |
| 17602 |
node.js
Node.js로 워터마킹 기능을 구현하는 방법
|
| 17600 | |
| 17594 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기