I’m making a simple search component using C#.
Source string example: Abcdef abcdef ABCdef
Trying to find substring: abc (or ABC, it does not matter in what case the user enters characters).
I wan’t to search substring in string ignoring case, but highlight result saving source string’s cases.
My desired result in this example is: Abcdef abcdef ABCdef
Should i use Regex.Replace here or something else?
I am trying this:
string result = Regex.Replace(sourceString, searchString, "<b>" + searchString + "</b>", RegexOptions.IgnoreCase);
This Regex replacing matches exactly with user’s input string. It’s almost OK for me, but as i said above, i need to save source string case.
Help please. Searched for information for like 3 hours and still can’t find any solution…