namespace textUtility { using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public static class StringExtension { public static bool IsNullOrEmpty(this string str) { return string.IsNullOrEmpty(str); } public static string Unwrap(this string str) { int leftIndex = str.IndexOf('(') + 1; int rightIndex = str.LastIndexOf(')') - 1; return str.Substring(leftIndex, rightIndex - leftIndex + 1); } public static string Replace(this string str, int index, int length, string newStr) { str = str.Remove(index, length); str = str.Insert(index, newStr); return str; } public static string Between(this string str, int startIndex, int endIndex) { if (startIndex > endIndex) { throw new Exception(); } else if (startIndex == endIndex) { return str[startIndex].ToString(); } else { return str.Substring(startIndex, endIndex - startIndex + 1); } } public static List ReplaceAll(this List strings, string oldValue, string newValue) { List results = new List(); for (int i = 0; i < strings.Count; i++) { results.Add(strings[i].Replace(oldValue, newValue)); } return results; } } }