3초기억력

ASP Function - 시작문자, 끝문자 사이의 문자열 추출하기 본문

플밍_ASP

ASP Function - 시작문자, 끝문자 사이의 문자열 추출하기

잠수콩 2011. 4. 13. 10:38
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



아래의 function 은 받은 변수에 시작문자, 끝 문자 사이의 문자열을 추출하는 겁니당

예를 들면

<img src="aklsdjfajdlaf.jpg" id="10000222003030" alt="머머" />

를 str 로 받아서 id=" 부터 " 까지의 사이값을 가져오고 싶을때...

getStringBetween(str, "id="", "" alt=")

하면 10000222003030 이 떨어짐.




'// html 태그중 시작태그점 끝태그점 사이의 값을 추출(S)
Function getStringBetween(str, sstart, send)
  Dim  PosStart, str_temp, PosEnd

If Len(str) > 0 then
PosStart = InStr(str, sstart)
str_temp = Mid(str, PosStart, Len(str))
PosEnd = InStr(str_temp, send) + PosStart - 1
If (PosStart > 0) And (PosEnd > 0) Then
getStringBetween = Mid(str, PosStart+Len(sstart), PosEnd-PosStart-Len(sstart))
Else
getStringBetween = ""
End If
Else
getStringBetween = ""
End If
End Function
'// html 태그중 시작태그점 끝태그점 사이의 값을 추출(S)
Comments