简体   繁体   中英

Formatted string parsing and updating

I need to replace specialy marked place holders in string with values. Similar to what string.Format does, but in a bit more advance way.

For instance: input string: "Welcome to {Binding Path=@city}!" Value for @city is "Boston" Output string should be "Welcome to Boston!".

I can successfully parse input string with regex and get the values. But to update the string I'm just using string.Replace. I'm currious if there's a better way to handle updates for such scenarious?

您可以使用Regex.Replace方法 ,但实际上只有在看到多个替换一个匹配项的地方(例如,一个字符串中有多个{Binding Path- @ city})时,才需要使用Regex.Replace方法

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM