Home Cooker Classes Others Rice CookerGX
Classes  >  regex  >  Replace(string,string)
regex class : Replace(string,string) method

Description

Gets a string that has replaced all strings that match the regular expression pattern in the input string.

Syntax

regexInstance.Replace(string source, string replace)

Arguments

ClassNameDescription
stringsourceA string which is searched.
stringreplaceA string which replaced.

Return value

ClassDescription
stringA string after replacing.

Sample code

//anyRegex is an any instance of regex type.

regex anyRegex = new regex("a+");

string result = anyRegex.Replace("aaabbbaaccc", "ddd");//result is "dddbbbdddccc".

Notes

It's a wrapper of the System.Text.RegularExpressions.Regex.Replace(String,String).

Links for reference

Copyright © Rice All rights reserved.