Using Regex.Replace() to replace text in a string
- by aspdotnetuser
Hi,
I want to use Regex.Replace() to loop through a string containing words that are separated by '//' to check if any of the words match a string value which has been passed to the method.
Here's my code at the moment:
public void CheckText(string text)
{
//Check text entered by user
string wordList = "word1//word2//word3 etc...";
string replaceString = "matched";
if (!string.IsNullOrEmpty(wordList))
{
return Regex.Replace(text, wordList); //How do I implement this part?
}
}
Please could someone help me with this? Any help/comments will be appreciated!
Thanks,