我在c#应用程序中有以下代码: -
string[] excludechar = { "|", "\\", "\"", "'", "/", "[", " ]", ":", "<", " >", "+", "=", ",", ";", "?", "*", " @" };
var currentgroupname = curItemSiteName;
for (int i = 0; i < excludechar.Length; i++)
{
if (currentgroupname.Contains(excludechar[i]))
currentgroupname.Replace(excludechar[i], "");
}
site.RootWeb.SiteGroups.Add(currentgroupname)
现在在我的abive代码中,我在currentgroupname
函数内传递的.ADD
变量将包含我在for循环中替换的所有特殊字符。如果我可以修改我的代码,那么任何人都可以这样做,以便.Replace实际上会替换currentgroupname
的原始字符串......
答案 0 :(得分:2)
您实际上并未将“已替换”字符串分配给with open ('myfile.txt', 'w') as filename:
shutil.move(r'/curr/dir/myfile.txt', r'/new/dir/myfile.txt')
currentgroupname
答案 1 :(得分:0)
使用某些 $scope.processForm = function($scope.formData) {
$http({
method : 'POST',
url : 'process.php',
data : $.param($scope.formData), // pass in data as strings
headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload)
})
regex?
别忘了使用:
var input = "<>+--!I/have:many@invalid\\|\\characters";
var result = Regex.Replace(input, @"\W", "");
Console.Write(result); //Ihavemanyinvalidcharacters