2

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#?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Aemz
  • 137
  • 1
  • 2
  • 9

1 Answers1

1

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"

mpacheco
  • 247
  • 2
  • 16
  • Good grief, I think that would be overkill. `String.Replace` should do the trick a lot easier. – Tim May 29 '13 at 07:55
  • He ask for a pattern, if is a simple pattern ok, he should be use replace. – mpacheco May 29 '13 at 07:59
  • @mpacheco can you please tell me what this function done? ereg_replace(" .*", "",... – Aemz May 29 '13 at 08:47
  • Do you mean, do you want delete all of "extensions" in string? Examnple string1.com string2.es string3.org the result should be string1 string2 string3? – mpacheco May 29 '13 at 09:09