Regex.IsMatch - it will return true or false.
& Regex.Matches - get the Matched words - Matches
var filterWords = GetTermsFromSPlist(log, secureUsrPwd);
try
{
string profanePattern = "";
bool isFirst = true;
filterWords.ToList().ForEach(i =>
{
if (isFirst)
{
profanePattern = "\\b" + i + "\\b";
isFirst = false;
}
else
profanePattern += "|\\b" + i + "\\b";
});
//Write Regex method
IsBlockedProfanity = Regex.IsMatch(htmltotext, profanePattern, RegexOptions.IgnoreCase);
if (IsBlockedProfanity)
{
var matches = Regex.Matches(htmltotext, profanePattern, RegexOptions.IgnoreCase);
string flaggedTermsString1 = string.Empty;
if (matches.Count > 0)
{
foreach (var bWord in matches)
{
flaggedTermsString1 += $"{bWord},";
}
}
}
& Regex.Matches - get the Matched words - Matches
var filterWords = GetTermsFromSPlist(log, secureUsrPwd);
try
{
string profanePattern = "";
bool isFirst = true;
filterWords.ToList().ForEach(i =>
{
if (isFirst)
{
profanePattern = "\\b" + i + "\\b";
isFirst = false;
}
else
profanePattern += "|\\b" + i + "\\b";
});
//Write Regex method
IsBlockedProfanity = Regex.IsMatch(htmltotext, profanePattern, RegexOptions.IgnoreCase);
if (IsBlockedProfanity)
{
var matches = Regex.Matches(htmltotext, profanePattern, RegexOptions.IgnoreCase);
string flaggedTermsString1 = string.Empty;
if (matches.Count > 0)
{
foreach (var bWord in matches)
{
flaggedTermsString1 += $"{bWord},";
}
}
}
No comments:
Post a Comment