kw
我想在大长度文本中搜索存储在变量中的关键字,并找到找到关键字的第一个 位置。下面的代码不做EXACT keyword match 。
if (webData.IndexOf(kw, StringComparison.OrdinalIgnoreCase) != -1)
{
found = true;
int pos = webData.IndexOf(kw, StringComparison.OrdinalIgnoreCase);
}
如何使用正则表达式来做到这一点?
Match match = Regex.Match(webData, @"^kw$", RegexOptions.IgnoreCase);
if (match.Success)
{
int pos = //Matching position
}