ASP มันไม่มี Function พวกนี้น่ะครับ อาจจะต้องใช้การ Replace พวก String ออกไปครับ
Code (ASP)
<%
Function RemChr(string, remove)
Dim i, j, tmp, strOutput
strOutput = ""
for j = 1 to len(string)
tmp = Mid(string, j, 1)
for i = 1 to len(remove)
tmp = replace( tmp, Mid(remove, i, 1), "")
if len(tmp) = 0 then exit for
next
strOutput = strOutput & tmp
next
RemChr = strOutput
End Function
' First remove numbers from string
chrToRemove = remchr("$10,000 max. amount paid","0123456789")
' then use new string as characters to remove
response.write remchr("$10,000 max. amount paid",chrToRemove) & "<br />"
chrToRemove = remchr("$10,000","0123456789")
Response.Write remchr("$10,000",chrToRemove)
%>
ลองดูตัวนี้ครับ
Date :
2014-02-26 17:58:22
By :
mr.win
No. 2
Guest
มันสามารถทำได้ง่ายๆๆอยู่แล้ว
Code (ASP)
<%
Response.Write(OnlyNumbers("4321 E3ast M 3.457 Soho Str77eet ctrlscho"))
'--- returns: 43213345777
%>
<%
Public Function OnlyNumbers(ByVal sValue)
Dim sAns
Dim sChar
Dim sNewString
Dim lLen
Dim lCtr
sAns = sValue
lLen = Len(sValue)
For lCtr = 1 To lLen
sChar = Mid(sAns, lCtr, 1)
If Asc(sChar) > 47 And Asc(sChar) < 58 Then
sNewString = sNewString & sChar
End If
Next
OnlyNumbers = sNewString
End Function
%>