본문 바로가기

classic asp

[classic asp] 정규식

<%

 

Function RegExpReturn(Str)

 

Dim RegExp, ResultStr

Set RegExp =  New RegExp

RegExp.IgnoreCase = True 'TRUE:대소문자 구분안함, FALSE:대소문자구분

RegExp.Global = True '전체, 첫번째 일치

RegExp.Pattern = "<.+?>" '태그제거 

'RegExp.Pattern = "\(.*?\)" '괄호제거

'RegExp.Pattern = "【.+?(】)" '【 】사이의 데이터

'RegExp.Pattern = "\(.+?(\))" '( ) 사이의 데이터

'RegExp.Pattern = "[^가-힣]"  '한글만

'RegExp.Pattern = "[^-0-9 ]"  '숫자만

'RegExp.Pattern = "[^-a-zA-Z]"  '영어만

'RegExp.Pattern = "[^-가-힣a-zA-Z0-9/ ]" '숫자와 영어 한글만 

'RegExp.Pattern = "<[^>]*>"   '태그만

'RegExp.Pattern = "[^-a-zA-Z0-9/ ]"    '영어 숫자만

 

ResultStr = RegExp.REPLACE(Str, "")

'strOutput = objRegExp.Test(strHTML) 'BOOLEAN 반환

RegExpReturn = ResultStr

Set RegExp = Nothing

 

End Function

 

 

' 배열로 처리시

Set sRegExp = NEW RegExp

sRegExp.IgnoreCase = True 'TRUE:대소문자 구분안함, FALSE:대소문자구분

sRegExp.Global = True '전체, 첫번째 일치

sRegExp.Pattern = "<img.+?>"

Set Match = sRegExp.Execute(Contents)

For Each arMatch In Match 'Match컬렉션 루프

arImage(0) = arMatch.Value '추출된 이미지태그

sRegExp.Pattern = "/data/.+"""

Set Match = sRegExp.Execute(arImage(0))

arImage(0) = Replace(Replace(Match(0), "/data/", ""), """", "")

arImage(0) = Replace(Replace(Match(0), "/data/", ""), """", "")

Exit For

Next

 

%>