[Visual Basic] Overloads Public Shared Function Replace( _ ByVal input As String, _ ByVal pattern As String, _ ByVal replacement As String _ ) As String [C#] public static string Replace( string input, string pattern, string replacement ); [C++] public: static String* Replace( String* input, String* pattern, String* replacement ); [JScript] public static function Replace( input : String, pattern : String, replacement : String ) : String;
The modified character string.
Substitutions are allowed only within a replacement pattern. For similar functionality within a regular expression, use a backreference (e.g.,\1- see below).
Character escapes and substitutions are the only special constructs recognized in a replacement pattern. All the syntactic constructs described below this point are allowed in regular expressions only and not recognized in replacement patterns. For example, the replacement pattern a*${foo}b inserts the string "a*" followed by the substring matched by the "foo" capturing group, if any, followed by the string "b". The * character is not recognized as a metacharacter within a replacement pattern. Similarly, $-patterns are not recognized within a regular expression matching pattern. Within a regular expression, $ means "end of string".
$123- Substitute the last substring matched by group number 123 (decimal).
${name) Substitute the last substring matched by a (?<name>) group.
Regex Class | Regex Members | System.Text.RegularExpressions Namespace | Regex.Replace Overload List