string inputStr=" xx xx "; inputStr=Regex.Replace(inputStr.Trim()," *"," ");

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 09:50:05
stringinputStr="xxxx";inputStr=Regex.Replace(inputStr.Trim(),"*","");stringinputStr="xxxx";inputStr=

string inputStr=" xx xx "; inputStr=Regex.Replace(inputStr.Trim()," *"," ");
string inputStr=" xx xx "; inputStr=Regex.Replace(inputStr.Trim()," *"," ");

string inputStr=" xx xx "; inputStr=Regex.Replace(inputStr.Trim()," *"," ");
Replace(inputStr.Trim()," *"," ")中Trim()方法是去掉字符串前后空白," *"," "是用后面一个空格" "替换掉前面的"*".,总的意思是用空格替换掉"*"并去掉inputStr字符串前后的空白.