我輸入的是:C#特定的單詞後刪除一切
[email protected];;
[email protected],./
[email protected]
[email protected]
我要的是經過我的「域」(存儲在陣列),以擺脫所有的字符。
所以輸出應該是:
[email protected]
[email protected]
[email protected]
[email protected]
我的代碼是:
string[] domains = richTextBox_domains.Text.Split(';');
char[] specialchars = ".!#$%^&*()-_=+[]{}\\|;:'\",.<>/?".ToCharArray();
for (int x = 0; x < domains.Length; x++)
{
for (int y = 0; y < specialchars.Length; y++)
{
string check = domains[x] + specialchars[y];
string aftertmp = "." + after.Substring(after.IndexOf('.') + 1);
if (aftertmp == check)
after = after.Replace(check, domains[x]);
}
}
它的工作,但並不總是在最後只有一個字符。
我會很樂意幫忙
你可以用一個簡單的正則表達式來解決它,例如:'(。*?@。*?\ .net | eu | org)' – Cybrus