3

I need a regex to move all alphabets from string (A-Z) and (a-z)..everything including any kind of special character should remain intact. I tried @"[^\d]" but it only returns numbers in string.

String : asd!@# $%dfdf4545D jasjkd #(*)jdjd56

desired output : !@# $%4545 #(*)56
NoobDeveloper
  • 1,877
  • 6
  • 30
  • 55

2 Answers2

15

Just replace all undesired characters with an empty string sequence:

string filtered = Regex.Replace(input, "[A-Za-z]", "");
Heinzi
  • 167,459
  • 57
  • 363
  • 519
2

Try the following regular expression:

[^a-zA-Z]

This will match all non-english letters.

Rui Jarimba
  • 11,166
  • 11
  • 56
  • 86