public static void Test2() { string a = "1234567890yyyy1234567890yyyy"; a = a.Replace("yy", "b"); MString str = new MString("ywyw1234567890yyyyyw1234567890yyyyyw"); MString str11 = str.MultiReplace("yw", "b"); MString str0 = str.MultiReplace("y", "y"); MString str1 = str.Substring(4); MString str2 = str.Substring(4, 10); MString str3 = str.Trim(); MString str4 = str.Trim(new char[] { 'y', 'w' }); MString str5 = str.TrimStart(new char[] { 'y', 'w' }); MString str6 = str.TrimEnd(new char[] { 'y', 'w' }); bool b0 = str.StartsWith(""); bool b1 = str.StartsWith("yw"); bool b2 = str.StartsWith("YW"); bool b3 = str.StartsWith("YW", true); bool b4 = str.StartsWith(new string[] { "y", "w" }); bool b5 = str.StartsWith(new string[] { "Y", "W" }); bool b6 = str.StartsWith(new string[] { "Y", "W" }, true); int idx1 = str.IndexOf("y"); int idx2 = str.IndexOf("w"); int idx3 = str.IndexOf("Y"); int idx4 = str.IndexOf("W"); int idx5 = str.IndexOf("W", true); int idx6 = str.IndexOf("W", 10, true); int idx7 = str.IndexOf("W", 10, 2, true); int idx8 = str.IndexOf(new string[] { "W", "Y" }); int idx9 = str.IndexOf(new string[] { "W", "Y" }, true); int idx0 = str.IndexOf(new string[] { "W", "Y" }, 10, true); MString mstr1 = str.Remove(4); MString mstr2 = str.Remove(4, 10); string[] strs0 = ((string)str).Split('y'); MString[] strs1 = str.Split('y'); string[] strs2 = ((string)str).Split('w'); MString[] strs3 = str.Split('w'); MString[] strs4 = str.MultiSplit('y'); }
private bool CheckAttribute(ref MString newDir, MString[] attrs, bool[] results) { for (int i = 0; i < newDir.Length; i++) { if (newDir[i] == '/') { MString str = newDir.Substring(i + 1); int attrEndIndex = str.IndexOf(new string[] { " ", "/" }); if (attrEndIndex == -1) { attrEndIndex = str.Length; } MString attr = str.Substring(0, attrEndIndex); int rmStartIdx = 0, rmCount = 0; bool isRightAttr = false; for (int j = 0; j < attrs.Length; j++) { if (attr == attrs[j]) { isRightAttr = true; results[j] = true; rmStartIdx = newDir.Substring(0, i).TrimEnd().Length; rmCount = (i - rmStartIdx + attrs[j].Length + 1); break; } } if (!isRightAttr) { Logger.Log(Status.Error_Attribute_Format, attr); return(false); } newDir = newDir.Remove(rmStartIdx, rmCount); i = rmStartIdx - 1; } } return(true); }