//regex_str = "( )+";//替换 为空格
regex_str = "(?i) ";//替换 为空格
tmpContent = Regex.Replace(tmpContent, regex_str, " ");
//regex_str="<script type=\\s*[^>]*>[^<]*?</script>";//替换<script>内容</script>为空格
regex_str = "(?is)<script[^>]*>.*?</script>";//替换<script>内容</script>为空格
tmpContent = Regex.Replace(tmpContent, regex_str, "");
//regex_str = "<[^<]*>";//替换Html标签为空
regex_str = "<[^<>]*>";//替换Html标签为空
tmpContent = Regex.Replace(tmpContent, regex_str, "");
//regex_str = "(\r\n)*";//替换\r\n为空
regex_str = @"[\r\n]*";//替换\r\n为空
tmpContent = Regex.Replace(tmpContent, regex_str, "", RegexOptions.IgnoreCase);
//regex_str = "\n*";//替换\n为空
regex_str = @"\n*";//替换\n为空
tmpContent = Regex.Replace(tmpContent, regex_str, "", RegexOptions.IgnoreCase);
//可以这样
regex_str = "\t*";//替换\t为空
tmpContent = Regex.Replace(tmpContent, regex_str, "", RegexOptions.IgnoreCase);
//可以
regex_str = "‘";//替换‘为’
tmpContent = Regex.Replace(tmpContent, regex_str, "’", RegexOptions.IgnoreCase);
//可以
regex_str = " +";//替换若干个空格为一个空格
tmpContent = Regex.Replace(tmpContent, regex_str, " ", RegexOptions.IgnoreCase);
其实你这些可以整合写成一个正则的。//regex_str = "( )+";//替换 为空格
regex_str = "(?i) ";//替换 为空格
tmpContent = Regex.Replace(tmpContent, regex_str, " ");
//regex_str="<script type=\\s*[^>]*>[^<]*?</script>";//替换<script>内容</script>为空格
regex_str = "(?is)<script[^>]*>.*?</script>";//替换<script>内容</script>为空格
tmpContent = Regex.Replace(tmpContent, regex_str, "");
//regex_str = "<[^<]*>";//替换Html标签为空
regex_str = "<[^<>]*>";//替换Html标签为空
tmpContent = Regex.Replace(tmpContent, regex_str, "");
//regex_str = "(\r\n)*";//替换\r\n为空
regex_str = @"[\r\n]*";//替换\r\n为空
tmpContent = Regex.Replace(tmpContent, regex_str, "", RegexOptions.IgnoreCase);
//regex_str = "\n*";//替换\n为空
regex_str = @"\n*";//替换\n为空
tmpContent = Regex.Replace(tmpContent, regex_str, "", RegexOptions.IgnoreCase);
//可以这样
regex_str = "\t*";//替换\t为空
tmpContent = Regex.Replace(tmpContent, regex_str, "", RegexOptions.IgnoreCase);
//可以
regex_str = "‘";//替换‘为’
tmpContent = Regex.Replace(tmpContent, regex_str, "’", RegexOptions.IgnoreCase);
//可以
regex_str = " +";//替换若干个空格为一个空格
tmpContent = Regex.Replace(tmpContent, regex_str, " ", RegexOptions.IgnoreCase);
其实你这些可以整合写成一个正则的。
-------------------------------------
Regex reg =
new
Regex(
@"(?is)(?:( |<script[^>]*>.*?</script>| +)|(<[^<>]*>|[\r\n\t]*)|(‘))"
);