SAS Tech & Tip

BookmarkSubscribeRSS Feed

[정규식] 정규식 (PERL 함수) 을 사용하여서 웹사이트(web site) URL 주소 검색

Started ‎06-14-2020 by
Modified ‎06-14-2020 by
Views 443

data BACK;

input URL $50.;

cards;

http://cafe.daum.net/statsas

http://RegExr.com/v1?2rjl6

backseungmin

http://www.statwith.pe.kr

http://gocoding.tistory.com/93

http://statwith.pe.kr/SAS/1.FUNCTION/F_list.htm#F04

statwith

;

 

* Perl Regular Expression (PRX) Metacharacters;

* 정규식 (PERL 함수) PRXMATCH 함수를 사용하여서 URL 형태의 데이터 선택;

data BACK1;

 set BACK;

    if prxmatch("/^(file|gopher|news|nntp|telnet|https?|ftps?|sftp):\/\/([a-z0-9-]+\.)+[a-z0-9]{2,4}.*$/", URL) = 1 then output;

run;

 

* 정규식 (PERL 함수) PRXCHANGE 함수를 사용하여서 URL 형태의 데이터를 ******로 변경;

data BACK2;

 set BACK;

     URL = prxchange("s/^(file|gopher|news|nntp|telnet|https?|ftps?|sftp):\/\/([a-z0-9-]+\.)+[a-z0-9]{2,4}.*$/******/",-1,URL);

run;

 

* 참고 PRXCHANGE

  : http://statwith.pe.kr/SAS/1.FUNCTION/F0329.htm

  : 패턴이 일치하는 경우 변경작업을 수행한다.

 

 

* 정규식 참조

  : http://statwith.pe.kr/SAS/1.FUNCTION/F0332.htm

 

* SAS 도움말 

 : https://support.sas.com/documentation/cdl/en/lefunctionsref/67960/HTML/default/viewer.htm#p0s9ilagex...

***********************************************************************

 

* 출처 (자주 쓰이는 정규식(Regular Expression))

 

  : http://gocoding.tistory.com/93

 

* URL

  /^(file|gopher|news|nntp|telnet|https?|ftps?|sftp):\/\/([a-z0-9-]+\.)+[a-z0-9]{2,4}.*$/

 

* 도메인 형태, http:// https:// 포함안해도 되고 해도 되고

  /^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/

 

* 도메인 형태, http:// https:// 꼭 포함

/^((http(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/

 

* 도메인 형태, http:// https:// 포함하면 안됨

/^[^((http(s?))\:\/\/)]([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/

 

 

 

 

전자우편 주소:

/^[a-z0-9_+.-]+@([a-z0-9-]+\.)+[a-z0-9]{2,4}$/

 

URL:

/^(file|gopher|news|nntp|telnet|https?|ftps?|sftp):\/\/([a-z0-9-]+\.)+[a-z0-9]{2,4}.*$/

 

HTML 태그 - HTML tags:

/\<(/?[^\>]+)\>/

 

전화 번호 - 예, 123-123-2344 혹은 123-1234-1234:

/(\d{3}).*(\d{3}).*(\d{4})/

 

날짜 - 예, 3/28/2007 혹은 3/28/07:

/^\d{1,2}\/\d{1,2}\/\d{2,4}$/

 

jpg, gif 또는 png 확장자를 가진 그림 파일명:

/([^\s]+(?=\.(jpg|gif|png))\.\2)/

 

1부터 50 사이의 번호 - 1과 50 포함:

/^[1-9]{1}$|^[1-4]{1}[0-9]{1}$|^50$/

 

16 진수로 된 색깔 번호:

/#?([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?/

 

적어도 소문자 하나, 대문자 하나, 숫자 하나가 포함되어 있는 문자열(8글자 이상 15글자 이하) - 올바른 암호 형식을 확인할 때 사용될 수 있음:

/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,15}/

 

 

 

숫자만 가능 : [ 0 ~ 9 ] 주의 : 띄어쓰기 불가능

/^[0-9]+$/

 

 이메일 형식만 가능

/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/

 

한글만 가능 : [ 가나다라 ... ] 주의 : ㄱㄴㄷ... 형식으로는 입력 불가능 , 띄어쓰기 불가능

/^[가-힣]+$/

 

한글,띄어쓰기만 가능 : [ 가나다라 ... ] 주의 : ㄱㄴㄷ... 형식으로는 입력 불가능 , 띄어쓰기 가능

/^[가-힣\s]+$/

 

영문만 가능 :

/^[a-zA-Z]+$/

 

 영문,띄어쓰기만 가능

/^[a-zA-Z\s]+$/

 

전화번호 형태 : 전화번호 형태 000-0000-0000 만 받는다. ]

/^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/

 

도메인 형태, http:// https:// 포함안해도 되고 해도 되고

/^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/

 

도메인 형태, http:// https:// 꼭 포함

/^((http(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/

 

도메인 형태, http:// https:// 포함하면 안됨

/^[^((http(s?))\:\/\/)]([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/

 

한글과 영문만 가능

/^[가-힣a-zA-Z]+$/;

 

숫자,알파벳만 가능

/^[a-zA-Z0-9]+$/;

 

주민번호, -까지 포함된 문자열로 검색

/^(?:[0-9]{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[1,2][0-9]|3[0,1]))-[1-4][0-9]{6}$/

 

 

*********************************************************
- 통계분석연구회
- 통계분석연구회(Statistics Analysis Study) 그룹 :https://www.facebook.com/groups/statsas
* 친구 호출 : 답글에서 @다음에 친구 이름이나 페이지명 작성 후 친구 선택
(예 : @통계분석연구회)
#통계 #빅데이터 #통계분석연구회 #데이터과학자 #bigdata #dataviz #statistics #Analytics
Version history
Last update:
‎06-14-2020 10:29 PM
Updated by:
Contributors

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Article Labels
Article Tags