我有以下的字符串。
Hdw.Instrument.Pins(\"PinName/").PSets(\"SignalName/").Apply()
我需要修剪上面的字符串,输出的结果应该是这样的。
Hdw.Instrument.Pins.PSets.Apply(应用)
我需要删除'()'之间的字符以及顺式。
string text = "Hdw.Instrument.Pins(\"PinName\").PSets(\"SignalName\").Apply()";
string t = Regex.Replace(text, "(\\(\"[^()]*\"\\)|\\(\\))", string.Empty);
Regex.Replace方法可以解决这个问题,你只需要写出正确的正则表达式就可以了。
我不会给你写代码,但这里有一个线索。