using UnityEngine; using System; using System.Collections; public static class ExtensionString { public static T ToEnum(this string str) { return (T)Enum.Parse(typeof(T), str); } public static string Remove(this string str, int startIndex, int endIndex, bool empty) { if (startIndex > endIndex) { throw new Exception(); } return str.Remove(startIndex, endIndex - startIndex + 1); } public static string Replace(this string str, int startIndex, int endIndex, string newStr) { if (startIndex > endIndex) { throw new Exception(); } str = str.Remove(startIndex, endIndex - startIndex + 1); str = str.Insert(startIndex, newStr); return str; } public static string Between(this string str, int startIndex, int endIndex) { if (startIndex > endIndex) { return ""; } else if (startIndex == endIndex) { return str[startIndex].ToString(); } else { return str.Substring(startIndex, endIndex - startIndex + 1); } } }