Search code examples
c#pattern-matchingereg-replace

ereg_replace equivalent in C#


I need to know how can we use $no = ereg_replace(" .*", "", $command[$i]); equivalent in c#, I am very newbie in pattern matching, can anyone please let me know the examples of pattern matching in c#?


Solution

  • Maybe you can use Regex.

    In this example, we want to delete all of HTML tags that we have in string.

    string newDescription = Regex.Replace("hello how are <b>you</b>", "<[^>]*>", string.Empty);
    

    newDescription now have "hello how are you"