0 out of 11 rated this helpful - Rate this topic

Regex.Replace Method

Replaces all occurrences of a character pattern defined by a regular expression with a specified replacement character string.

Name Description
Regex.Replace (String, MatchEvaluator) Replaces all occurrences of a character pattern defined by the regular expression specified in the Regex constructor. A MatchEvaluator delegate is called at each match to evaluate the replacement.

Supported by the .NET Compact Framework.

Regex.Replace (String, String) Replaces all occurrences of a specified regular expression pattern with a replacement string, starting at the first character in the input string.

Supported by the .NET Compact Framework.

Regex.Replace (String, MatchEvaluator, Int32) Replaces up to a specified number of occurrences of a pattern defined by the regular expression specified in the Regex constructor with a replacement string, starting at the first character in the input string. A MatchEvaluator delegate is called at each match to evaluate the replacement.

Supported by the .NET Compact Framework.

Regex.Replace (String, String, Int32) Replaces up to a specified number of occurrences of a pattern defined by the regular expression specified in the Regex constructor with a specified replacement string, starting at the first character in the input string.

Supported by the .NET Compact Framework.

Regex.Replace (String, String, MatchEvaluator) Replaces all occurrences of a character pattern defined by a regular expression with a replacement character string starting at the first character. A MatchEvaluator delegate is called at each match to evaluate the replacement.

Supported by the .NET Compact Framework.

Regex.Replace (String, String, String) Replaces all occurrences of matches defined by the regular expression with a replacement string, starting at the first character in the input string.

Supported by the .NET Compact Framework.

Regex.Replace (String, MatchEvaluator, Int32, Int32) Replaces up to a specified number of occurrences of a pattern specified in the Regex constructor with a replacement string, starting at a specified character position in the input string. A MatchEvaluator delegate is called at each match to evaluate the replacement.

Supported by the .NET Compact Framework.

Regex.Replace (String, String, Int32, Int32) Replaces up to a specified number of occurrences of a pattern in the input string defined by the regular expression specified in the Regex constructor with a specified replacement string, starting at a specified character position in the input string.

Supported by the .NET Compact Framework.

Regex.Replace (String, String, MatchEvaluator, RegexOptions) Replaces all occurrences of a character pattern defined by a specified regular expression with a replacement character string starting at the first character. Options can be specified to modify matching behavior and a MatchEvaluator delegate is called at each match to evaluate the replacement.

Supported by the .NET Compact Framework.

Regex.Replace (String, String, String, RegexOptions) Replaces all occurrences of a pattern defined by a specified regular expression with a specified replacement character string, starting at the first character in the input string. Options can be specified to modify matching behavior.

Supported by the .NET Compact Framework.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Missing Overloads

I only have 4 overloads available. It appears the overloads where you specify the maximum number of matches are missing. Such as:

Regex.Replace (String, MatchEvaluator, Int32, Int32)

Am I doing something wrong?

---


The reason you're only seeing 4, instead of all these listed here is because some overloads are static methods and some are instance methods. So if you need to use the other overloads, you need to create an instance of the class Regex and use the method on the object.