How to use Regex.Replace for string replacement in C#

1 Answer

0 votes
using System;
using System.Text.RegularExpressions;

namespace ConsoleApplication_C_Sharp
{
    static class Program
    {
        static void Main()
        {
            string s = "php pdp dhp paip c#";

            string reg = Regex.Replace(s, "p.p", "PHP");

            Console.WriteLine(s);
            Console.WriteLine(reg);
        }
    }
}


/*
run:
   
php pdp dhp paip c#
PHP PHP dhPHPaip c#
    
*/

 



answered Oct 15, 2018 by avibootz

Related questions

1 answer 160 views
2 answers 307 views
1 answer 177 views
1 answer 184 views
184 views asked Oct 23, 2020 by avibootz
...