开发者

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?


You could use the Regex.Replace method, but you really only need it if you see having multiple spots to replace of one match (EX: multiple {Binding Path-@city} in one string).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜