public Replace ( string input, System evaluator ) : string | ||
input | string | |
evaluator | System | |
return | string |
string input = "The quick brown fox jumps over the lazy dog"; string pattern = "quick"; string replacement = "slow"; string output = Regex.Replace(input, pattern, replacement); // output: "The slow brown fox jumps over the lazy dog"
string input = "abc123def456"; string pattern = "[^0-9]"; string replacement = ""; string output = Regex.Replace(input, pattern, replacement); // output: "123456"
string input = "Hello\nworld\nhow are you?"; string pattern = @"^(\w)"; string replacement = "Prefix $1"; string output = Regex.Replace(input, pattern, replacement, RegexOptions.Multiline); // output: "Prefix H\nPrefix w\nPrefix h are you?"In all of these examples, we're using the System.Text.RegularExpressions namespace, which is part of the .NET Framework.
public Replace ( string input, System evaluator ) : string | ||
input | string | |
evaluator | System | |
return | string |