之前的代码>>>
dateTime1 = new DateTime(2015, 5, 24);
line2 ( some code)...;
line3 ( some code)...;
DateTimePicker.Value = dateTime1;
正则表达式后的代码>>>
line1 ---> ( will be cleared)
line2 ---> ( some code)...;
line3 ---> ( some code)...;
DateTimePicker.Value = new DateTime(2015, 5, 24);
我试过这个搜索模式
( ^:b*dateTime[:d]{.+}\n{.+}\n{.+}\ndateTime[:d];$ )
但没有结果
答案 0 :(得分:0)
试试这个
string input =
"dateTime1 = new DateTime(2015, 5, 24);" +
"line2 ( some code)...;" +
"line3 ( some code)...;" +
"DateTimePicker.Value = dateTime1;";
string pattern = "(?'line1'[^;]*);(?'line2'[^;]*);(?'line3'[^;]*);(?'line4'[^;]*)";
Regex expr = new Regex(pattern, RegexOptions.Singleline);
string output = expr.Replace(input, "${line2};${line3};${line1};");