我目前有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中?预先感谢。
根据需要,您可以遍历数组
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)