regex c# string replace code example
Example 1: c sharp string replace
// You can use the function 'Replace()' to replace all instances
// of a string or character with a given string or character.
str = "Hello World!"
str.Replace('o', 'e');
// Output: "Helle Werld!"
Example 2: c# regex get matched string
Regex filter = new Regex(@"(\d+)");
foreach (var item in checkedListBox1.CheckedItems)
{
var match = filter.Match(item.ToString());
if (match.Success)
{
MessageBox.Show(match.Value);
}
}