아미(아름다운미소)

asp 변수에서 숫자만 걸러내는 함수 본문

랭귀지/ASP

asp 변수에서 숫자만 걸러내는 함수

유키공 2019. 10. 23. 11:14

숫자 ASCII코드는 48번부터 57번 입니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Function RefNumeric(inputStr)
 
    a = inputStr
    result = ""
    For i = 1 To Len(a)
        checkStr = Mid(a, i, 1)
        If Asc(checkStr) > 47 And Asc(checkStr) < 58 Then
            result = result & checkStr
        End If
    Next
    RefNumeric = result
 
End Function
 
inputStr = "테 스 트12345 67890"
Response.write RefNumeric(inputStr)

결과 : 1234567890

Comments