如何使用Delphi將給定字符串中的特殊字符替換爲空格或僅刪除它?以下在C#中有效,但我不知道如何在Delphi中編寫它。如何使用delphi替換給定字符串中的特殊字符與空格或無空格
public string RemoveSpecialChars(string str)
{
string[] chars = new string[] { ",", ".", "/", "!", "@", "#", "$", "%", "^", "&", "*", "'", "\"", ";","_","(", ")", ":", "|", "[", "]" };
for (int i = 0; i< chars.Lenght; i++)
{
if (str.Contains(chars[i]))
{
str = str.Replace(chars[i],"");
}
}
return str;
}
我們能不能有任何其他邏輯..除了這個......要更換給出一個字符串 – user3345195