zoukankan      html  css  js  c++  java
  • C# 匹配开始字符和结束字符

    /// <summary>
            /// 获得字符串中开始和结束字符串
            /// </summary>
            /// <param name="str">字符串</param>
            /// <param name="s">开始</param>
            /// <param name="e">结束</param>
            /// <returns></returns>
            public static List<string> GetValue(string str, string s, string e)
            {
                return Regex.Matches(str, "[.\s\S]*?(?<=(" + s + "))[.\s\S]*?(?<=(" + e + "))", RegexOptions.Multiline | RegexOptions.Singleline)
                   .Cast<Match>()
            .Select(t => t.Value.LastIndexOf(s) == -1 ? t.Value :  t.Value.Substring(t.Value.LastIndexOf(s))).ToList();
            }
         private void GetAllDataStr(string DataValue)
            {
                try
                {
                    string regx = "(?<=(01))[.\s\S]*?(?=(04))";
                    if (string.IsNullOrWhiteSpace(DataValue))
                        return;
                    bool isMatch = Regex.IsMatch(DataValue, regx);
                    if (!isMatch)
                        return;
                    MatchCollection matchCol = Regex.Matches(DataValue, regx);
                    string[] result = new string[matchCol.Count];
                    if (matchCol.Count > 0)
                    {
                        for (int i = 0; i < matchCol.Count; i++)
                        {
                            result[i] = "01" + matchCol[i].Value + "04";
    
                            StrToASCII(result[i]);
                        }
                    }
                }
                catch(Exception ex)
                {
                    WriteLog.Write(ex.Message);
                }
            }
  • 相关阅读:
    Day Six(Beta)
    Day Five (beta)
    Day Four(Beta)
    Day Three(Beta)
    Day Two(Beta)
    Day One(Beta)
    项目冲刺——总结
    beta版本贡献率
    软件工程实践总结
    团队作业--Beta版本冲刺
  • 原文地址:https://www.cnblogs.com/Duriyya/p/13631894.html
Copyright © 2011-2022 走看看