2014-11-08 86 views

回答

0

舉個例子。請先嚐試在互聯網上搜索解決方案。如果找不到直接的解決方案,請在此論壇中提問。

不是C#的確切代碼,而是將其視爲僞代碼。有很多方法可以做到這一點。

// First method 
int first_index_of = s.find(input_String); 
String temp = input_String.substr(first_index_of, input_String.length); 
temp = temp.replace("Old", "New"); 
input_String = input_String.substring(0,first_index_of) + temp; 

//第二種方法

int i = 0; 
while (didn't reach end of string){ 
find next occurrence starting from index i 

// Ignore the first occurrence and Replace all other occurrences 
if (Ctr >1) 
    replace the string 

// Exit if no more sub strings found 
} 

這些都只是僞代碼。我希望你在使用它之前先做一些工作。