我如何在经典ASP中搜索字符串以查找数组中的任何字符?

问题描述 投票:0回答:1

我目前有ASP的以下代码,如果在搜索字符串中出现特定的非拉丁字符“д”,则将得到所需的响应,如下所示。

myQuery = request("myQuery")

If InStr(1, myQuery, "д", 1) > 0 then
    Response.write "Query from languages ......  detected." 
 Else 
    Response.write "Continue searching English/Latin archive."
End if

但是我如何用一个字符数组替换我的单个字符:

myArray = Array("ß","ü","ş","ğ", "ä", "д", "ф")

换句话说,如何检查myArray中的任何字符是否出现在myQuery中?预先感谢。

arrays search asp-classic
1个回答
0
投票

根据需要,您可以遍历数组

For Each x In myArray 
    If InStr(1, myQuery, x, 1) > 0 then
        Response.write x + " was detected." 
    Else 
        Response.write "Continue searching English/Latin archive."
    End if
Next

或使用正则表达式进行一次测试

Dim myRegExp, FoundMatch
Set myRegExp = New RegExp
myRegExp.Pattern = "[ßüşğäдф]"
FoundMatch = myRegExp.Test(myQuery)
© www.soinside.com 2019 - 2024. All rights reserved.