誰能幫我做任何任何字符串的C#中的字符串替換開始「startingChars」,並以「endingChars」結尾......類似的東西:C#替換表達式匹配的開始結束
Regex.Replace(strToReplaceIn, "startingChars[anyNumberOfChars]endingChars", myFunction(anyNumberofChars));
其中strStartingChars和strEndingChars是兩個字符串,並myFunction是定義
例如,如果一開始是"Hello, I need to replace startingCharsWITH_SOMETHINGendingChars, ...."
得到的結果是:"Hello, I need to replace myFunctionResult("WITH_SOMETHING"), ..."
請讓我知道Regex.Replace表達,這將有助於,問題是沒有找到匹配的表達式,但替換...我怎麼可以參考
anyNumberOfChars
在表達式的替換參數?
我希望這是很清楚...謝謝你
這正是想我需要......非常感謝你,一些備註: '{return「myFunctionResult(」+ match.Groups [「contents」]。Value +「)」; }'成爲我myFunction(match.Groups [「contents」]。Value;' –
@SandraS。很高興它幫助:)乾杯 –