日期:2014-05-18 浏览次数:21092 次
Dim keywords = "超G强抗t△干dst△扰敏■■感※◇词 kljb过&滤jb一■&№正■№则匹◎←配代crSBtr码(只……支{持^中#^文)" Dim blackwords = "(超强|抗干扰|敏感词|过滤|正则匹配|代码|只支持|中文)" blackwords = Regex.Replace(blackwords, "(?<=[\u4e00-\u9fa5])[^\|\u4e00-\u9fa5]*(?=[\u4e00-\u9fa5])", "[^\u4e00-\u9fa5]*") Dim Matchs = Regex.Matches(keywords, blackwords) For Each Match As Match In Matchs If Match.Success Then Debug.Print("敏感字符: """ & Match.Value & """ 位于该字符串第" & (Match.Index + 1).ToString & "个字符起共" & Match.Length.ToString & "个字符") End If Next