/// <summary> /// 识别所有标识符“{标识名称}{序号}” /// </summary> /// <param name="errDesc">带格式的错误描述,需要补充参数</param> /// <returns>返回多个SignStruct,每个SignStruct结构是一个标识符对象,结构为{标识名称,序号,标识符}</returns> public List <SignStruct> GetProperties(string errDesc) { List <SignStruct> signDictionary = new List <SignStruct>(); string pattern = @"\{[a-z,A-Z]+\}\s*\{[0-9]+\}"; MatchCollection result = Regex.Matches(errDesc, pattern, RegexOptions.None); for (int i = 0; i < result.Count; i++) { string str = result[i].Value; string[] tempString = str.Split('{'); // 对应标识符“{标识名称}{序号}”中的标识名称 string sign = tempString[1].Substring(0, tempString[1].Length - 1); // 对应标识符“{标识名称}{序号}”中的序号 string num = tempString[2].Substring(0, tempString[2].Length - 1); SignStruct signObject = new SignStruct(sign, num, result[i].Value); signDictionary.Add(signObject); } return(signDictionary); }
/// <summary> /// 识别所有标识符“{标识名称}{序号}” /// </summary> /// <param name="errDesc">带格式的错误描述,需要补充参数</param> /// <returns>返回多个SignStruct,每个SignStruct结构是一个标识符对象,结构为{标识名称,序号,标识符}</returns> public List<SignStruct> GetProperties(string errDesc) { List<SignStruct> signDictionary = new List<SignStruct>(); string pattern = @"\{[a-z,A-Z]+\}\s*\{[0-9]+\}"; MatchCollection result = Regex.Matches(errDesc, pattern, RegexOptions.None); for (int i = 0; i < result.Count; i++) { string str = result[i].Value; string[] tempString = str.Split('{'); // 对应标识符“{标识名称}{序号}”中的标识名称 string sign = tempString[1].Substring(0, tempString[1].Length - 1); // 对应标识符“{标识名称}{序号}”中的序号 string num = tempString[2].Substring(0, tempString[2].Length - 1); SignStruct signObject = new SignStruct(sign, num, result[i].Value); signDictionary.Add(signObject); } return signDictionary; }