/// <summary> /// 提取文本中@对象 @用户 /// http://blog.csdn.net/hfut_jf/article/details/49745701 /// </summary> /// <param name="str"></param> /// <returns></returns> public static List <string> FindAtFromStr(string str) { var matchs = RegexHelper.FindMatchs(ConvertHelper.GetString(str), "@[\u4e00-\u9fa5a-zA-Z0-9_-]{2,30}"); var list = matchs?.Where(x => x.Success).Select(x => x.Value).Distinct().ToList(); if (list == null) { list = new List <string>(); } return(list); }
/// <summary> /// 提取文本中的话题,格式:#话题# /// http://blog.csdn.net/hfut_jf/article/details/49745701 /// </summary> /// <param name="str"></param> /// <returns></returns> public static List <string> FindTagsFromStr(string str) { var matchs = RegexHelper.FindMatchs(ConvertHelper.GetString(str), "#[^#]+#"); var list = matchs?.Where(x => x.Success).Select(x => x.Value).Distinct().ToList(); if (list == null) { list = new List <string>(); } return(list); }