System.Text.RegularExpressions.Regex.Replace C# (CSharp) Method

Replace() public method

public Replace ( string input, System evaluator ) : string
input string
evaluator System
return string
        public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator)
        {
            throw null;
        }

Same methods

Regex::Replace ( string input, System evaluator, int count ) : string
Regex::Replace ( string input, System evaluator, int count, int startat ) : string
Regex::Replace ( string input, string replacement ) : string
Regex::Replace ( string input, string pattern, System evaluator ) : string
Regex::Replace ( string input, string pattern, System evaluator, System options ) : string
Regex::Replace ( string input, string pattern, System evaluator, System options, System matchTimeout ) : string
Regex::Replace ( string input, string replacement, int count ) : string
Regex::Replace ( string input, string replacement, int count, int startat ) : string
Regex::Replace ( string input, string pattern, string replacement ) : string
Regex::Replace ( string input, string pattern, string replacement, System options ) : string
Regex::Replace ( string input, string pattern, string replacement, System options, System matchTimeout ) : string

Usage Example

Example #1
1
        /// <summary/>
        protected CodeFormat()
        {
            //generate the keyword and preprocessor regexes from the keyword lists
            var r = new Regex(@"\w+|-\w+|#\w+|@@\w+|#(?:\\(?:s|w)(?:\*|\+)?\w+)+|@\\w\*+");
            string regKeyword = r.Replace(Keywords, @"(?<=^|\W)$0(?=\W)");
            string regPreproc = r.Replace(Preprocessors, @"(?<=^|\s)$0(?=\s|$)");
            r = new Regex(@" +");
            regKeyword = r.Replace(regKeyword, @"|");
            regPreproc = r.Replace(regPreproc, @"|");

            if (regPreproc.Length == 0)
            {
                regPreproc = "(?!.*)_{37}(?<!.*)"; //use something quite impossible...
            }

            //build a master regex with capturing groups
            var regAll = new StringBuilder();
            regAll.Append("(");
            regAll.Append(CommentRegex);
            regAll.Append(")|(");
            regAll.Append(StringRegex);
            if (regPreproc.Length > 0)
            {
                regAll.Append(")|(");
                regAll.Append(regPreproc);
            }
            regAll.Append(")|(");
            regAll.Append(regKeyword);
            regAll.Append(")");

            RegexOptions caseInsensitive = CaseSensitive ? 0 : RegexOptions.IgnoreCase;
            CodeRegex = new Regex(regAll.ToString(), RegexOptions.Singleline | caseInsensitive);
        }
All Usage Examples Of System.Text.RegularExpressions.Regex::Replace