I'm trying to add this snippet to my code:
public string Highlight(string InputTxt)
{
string Search_Str = txtSearch.Text.ToString();
// Setup the regular expression and add the Or operator.
Regex RegExp = new Regex(Search_Str.Replace(" ", "|").Trim(), RegexOptions.IgnoreCase);
// Highlight keywords by calling the
//delegate each time a keyword is found.
return RegExp.Replace(InputTxt, new MatchEvaluator(ReplaceKeyWords));
// Set the RegExp to null.
RegExp = null;
}
However, for some reason, "Regex" is not showing up - the type or namespace is not found. I suppose I must be using a newer version of C# - can anybody help me out with the newer way to do this? I AM using System.Text.RegularExpressions.Regex - maybe they got rid of it entirely?
using System.Text.RegularExpressions;
Try that namespace.
I AM using System.Text.RegularExpressions.Regex
Make sure that in your using directive, you only reference the namespace, not the class:
using System.Text.RegularExpressions;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With