我正在寻找最有效的方法来获取字符串的一部分,并使用HTML注释作为开始/结束点。返回带注释标记的字符串部分
因此,例如,我想用
<!-- START: Variable -->
stuff goes here
<!-- END: Variable -->
该字符串应该只是东西在评论之间。我做了一个帮手,但对.net来说不是很好。
@helper readPattern(string filepath, string patternSection = null) {
TextReader tr = new StreamReader(filepath);
string SplitBy = "<!-- START: "+patternSection+" -->";
string fullLog = tr.ReadToEnd();
fullLog.Trim().StartsWith("<!-- " + patternSection+ " -->");
//string[] sections = fullLog.Split(new string[] { SplitBy }, StringSplitOptions.RemoveEmptyEntries);
<div class="@patternSection">@fullLog</div>
}
我不需要拆呢,我只需要输出或由我通过这个助手的意见修剪。
你可以使用子串2次 –