Answers for "c# replace string case insensitive"

C#
1

c# replace string case insensitive

class Program
{
    static void Main()
    {
        string input = "hello WoRlD";
        string result = 
           Regex.Replace(input, "world", "csharp", RegexOptions.IgnoreCase);
        Console.WriteLine(result); // prints "hello csharp"
    }
}
Posted by: Guest on March-29-2020
0

c# Replace Strings In C#

//The following example replaces all commas with a colon in a string.
//^_*
// Replace a char  
string odd = "1, 3, 5, 7, 9, 11, 13, 15, 17, 19";  
Console.WriteLine($ "Original odd: {odd}");  
string newOdd = odd.Replace(',', ':');  
Console.WriteLine($ "New Odd: {newOdd}");  
//The following example replaces all “Beniwal” with an empty string so only first names are copied to the new string.

string authors = "Mahesh Beniwal, Neel Beniwal, Raj Beniwal, Dinesh Beniwal";  
Console.WriteLine($ "Authors with last names: {authors}");  
// Remove all Beniwal with space and remove space with empty string  
string firstNames = authors.Replace(" Beniwal", "");  
Console.WriteLine($ "Authors without last names: {firstNames}");
Posted by: Guest on December-12-2020

Code answers related to "c# replace string case insensitive"

C# Answers by Framework

Browse Popular Code Answers by Language