我有一个像这样的文本文件中包含一些行的文件
This is a test value with {MyTestValue = 0.34} How do I delete the test value? My line also has {MySecondTestValue = 0.35}
MyTestValue
的值在每一行中不是相同的值。
有没有办法确定直到右括号的字符数并删除括号内的所有内容。所以我的输出会是这样的:
This is a test value with {} How do I delete the test value? My line also has {MySecondTestValue = 0.35}
最佳答案
可能通过正则表达式实现:
String source = "This is a test value with {MyTestValue = 0.34} How do I delete the test value?";
String result = Regex.Replace(source, "{.*}", (MatchEvaluator) ((match) => "{}"));
关于c# - 从 C# 中的一行中删除子字符串 "dynamically",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31426177/