• 搜索结果格式化



            private string FormatContext(string SearchKeyWords, string AllWords)
            {
                string ResultWorlds = string.Empty;
                AllWords = Regex.Replace(Regex.Replace(AllWords, @"\[pic\].*?\[/pic\]", "", RegexOptions.IgnoreCase), @"<[^>]*>", "", RegexOptions.IgnoreCase).Trim();
                int WordsCount = AllWords.Length;
                if (AllWords.Contains(SearchKeyWords))
                {
                    if (WordsCount <= 100)
                    {
                        ResultWorlds = Regex.Replace(ResultWorlds, SearchKeyWords, "<em>" + SearchKeyWords + "</em>", RegexOptions.IgnoreCase);
                    }
                    else
                    {
                        ResultWorlds = AllWords.Substring(AllWords.IndexOf(SearchKeyWords));
                        if (ResultWorlds.Length > 100)
                        {
                            ResultWorlds = ResultWorlds.Substring(0, 97) + "...";
                            ResultWorlds = Regex.Replace(ResultWorlds, SearchKeyWords, "<em>" + SearchKeyWords + "</em>", RegexOptions.IgnoreCase);
                        }
                    }
                }
                else
                {
                    if (WordsCount <= 100)
                    {
                        ResultWorlds = AllWords;
                    }
                    else
                    {
                        ResultWorlds = AllWords.Substring(0, 97) + "...";
                    }
                }

                return ResultWorlds;
            }

  • 相关阅读:
    cuda cdnn 安装
    神经网络的例子
    理解pytorch几个高级选择函数(如gather)
    opencv 膨胀和腐蚀
    PyPDF2
    百度ocr
    opencv 代码集合
    tesseract cuda pytorch安装
    Vue路由钩子 afterEach beforeEach区别
    (转载)中文区位码、国标码、机内码、输入码、字形码
  • 原文地址:https://www.cnblogs.com/stulife/p/1783635.html
Copyright © 2020-2023  润新知