我有這樣的字符串:字符串第一個字前更換空格,然後刪除多餘的空格
string stuff = " this is something you could use one day";
我使用下面的函數刪除多餘的空格:
申請後private string removeThem(string str) {
if (str!= null){
return Regex.Replace(str, @"\s+", " ");
}else{
return "";
}
}
所以該功能我得到:
" this is something you could use one day"
,但我想:
"this is something you could use one day"
怎麼辦?
你可以使用裝飾做regex.replace後,對不對? – Jerry