使用asp和RegExp删除特殊代码

时间:2010-09-30 12:40:14

标签: regex asp-classic

嗨,我想知道是否有人知道如何从asp经典中的字符串中删除特殊代码和空格?

感谢

3 个答案:

答案 0 :(得分:0)

不知道asp但只是传递替换所有不是[^ 0-9a-fA-F]

答案 1 :(得分:0)

您可以使用REPLACE函数http://devguru.com/technologies/vbscript/13958.asp

轻松地从字符串中删除字符

您可以使用REGEXP OBJECT http://www.devguru.com/technologies/vbscript/14108.asp

实现正则表达式搜索字符串

答案 2 :(得分:0)

@Jay:如果您不想使用正则表达式路线,这可能对您有用:

<%
Option Explicit

Function alphanum(ByVal sText)
    Dim sChr, i

    If NOT IsNumeric(sText) Then
        For i = 1 To Len(sText)
            sChr = Mid(sText, i, 1)

            If IsNumeric(sChr) Then
                alphanum = alphanum & sChr
            Else
                If sChr = " " OR (Asc(LCase(sChr)) <= 122 AND Asc(LCase(sChr)) >= 97) Then
                    alphanum = alphanum & sChr
                End If
            End If
        Next
    Else
        alphanum = sText
    End If
End Function


Dim sInput

sInput = alphanum("$%^ (O_oh)")
sInput = Replace(sInput, " ", "") 

Response.Write sInput
%>