Split string, example here
var hello = "Hello World";
I’m trying to get the result to be "Hello World" with spans around the matching "l"
string[] words = hello.ToLower().Split("l");
var resultString = "";
for (int i = 0; i < words.Length; i++)
{
// now we have split the string how do find the missing 'l' and wrap a span around them
resultString += words[i].ToString();
}
// result is heo word
Console.WriteLine(resultString);
// Trying to get the result to be "He<span>l</span><span>l</span>o Wor<span>l<span>d
>Solution :
var result = Regex.Replace(hello, "l", x => $"<span>{x}</span>");