.NET Regular Expressions
HTML去空白回车换行
private static readonly Regex REGEX_LINE_BREAKS = new Regex(@"\n\s*", RegexOptions.Compiled); private static readonly Regex REGEX_LINE_SPACE = new Regex(@"\n\s*\r", RegexOptions.Compiled); private static readonly Regex REGEX_SPACE = new Regex(@"( )+", RegexOptions.Compiled); var targetHtml = REGEX_SPACE.Replace(REGEX_LINE_SPACE.Replace(REGEX_LINE_BREAKS.Replace(baseInfoHtml, ""), ""), " ");
Ref:正则表达式30分钟入门教程
Ref:常用正则表达式
Ref:Matching Balanced Constructs with .NET Regular Expressions
Ref:RegexOne
Ref:RegExLib
Ref:Regex101