Using Regex.Replace() to replace text in a string
Posted
by aspdotnetuser
on Stack Overflow
See other posts from Stack Overflow
or by aspdotnetuser
Published on 2010-05-26T10:09:04Z
Indexed on
2010/05/26
10:11 UTC
Read the original article
Hit count: 502
c#
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,
© Stack Overflow or respective owner