Wednesday, August 14, 2019

Regex.IsMatch & Regex.Matches- get the Matched words - Matches

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},";
                                }
                            }
}

No comments:

Update or edit status filed in JIRA issue

the status field is a special case and can't be updated directly, which is the second problem here. Changing a status in Jira is called ...