CSharp examples for System:String Case
Performs a case insensitive string replacement.
// Copyright ? 2011, Grid Protection Alliance. All Rights Reserved. using System.Text.RegularExpressions; using System.Text; using System.IO;// ww w . ja v a2s .c o m using System.Globalization; using System.ComponentModel; using System.Collections.Generic; using System; public class Main{ /// <summary> /// Performs a case insensitive string replacement. /// </summary> /// <param name="value">The string to examine.</param> /// <param name="fromText">The value to replace.</param> /// <param name="toText">The new value to be inserted</param> /// <returns>A string with replacements.</returns> public static string ReplaceCaseInsensitive(this string value, string fromText, string toText) { return (new Regex(fromText, RegexOptions.IgnoreCase | RegexOptions.Multiline)).Replace(value, toText); } }