//============================================================ // <T>删除字符串数组两侧的空字符串。</T> // // @param lines 字符串数组 // @param blankLine 是否保持空行 // @return 字符串数组 //============================================================ public static string[] TrimLines(string[] lines, bool blankLine) { if (lines != null) { FStrings result = new FStrings(); for (int n = 0; n < lines.Length; n++) { string line = lines[n].Trim(); if (blankLine) { result.Push(line); } else if (!blankLine && !RString.IsEmpty(line)) { result.Push(line); } } return(result.ToArray()); } return(null); }
//============================================================ // <T>分割格式字符串。</T> // // @param value 格式字符串 // @return 字符串数组 //============================================================ protected static String[] Split(String format) { FStrings items = new FStrings(); FString buffer = new FString(); char[] chars = format.ToLower().ToCharArray(); int length = chars.Length; for (int n = 0; n < length; n++) { String sub = null; if (n <= (length - 4)) { if (('y' == chars[n]) && ('y' == chars[n + 1]) && ('y' == chars[n + 2]) && ('y' == chars[n + 3])) { sub = "yyyy"; } else if (('h' == chars[n]) && ('h' == chars[n + 1]) && ('2' == chars[n + 2]) && ('4' == chars[n + 3])) { sub = "hh24"; } } if (sub == null && n <= (length - 2)) { if (('y' == chars[n]) && ('y' == chars[n + 1])) { sub = "yy"; } else if (('m' == chars[n]) && ('m' == chars[n + 1])) { sub = "mm"; } else if (('d' == chars[n]) && ('d' == chars[n + 1])) { sub = "dd"; } else if (('m' == chars[n]) && ('i' == chars[n + 1])) { sub = "mi"; } else if (('s' == chars[n]) && ('s' == chars[n + 1])) { sub = "ss"; } } if (sub != null) { if (!buffer.IsEmpty) { items.Push(buffer.Flush()); } items.Push(sub); n += sub.Length - 1; } else { buffer.Append(format[n]); } } if (!buffer.IsEmpty) { items.Push(buffer.Flush()); } return(items.ToArray()); }