using System.Text.RegularExpressions; namespace AutoGroupGenerator { /// /// String helpers for formatting identifiers and file names. /// public static class StringExtensions { #region Static Methods /// /// Converts a string to a more readable, spaced format. /// /// The source string. /// A readable representation of the string. public static string ToReadableFormat(this string input) { if (string.IsNullOrEmpty(input)) { return input; } input = Regex.Replace(input, "^(m_|k_)", ""); input = Regex.Replace(input, "(\\B[A-Z])", " $1"); return char.ToUpper(input[0]) + input.Substring(1); } /// /// Removes the extension from a file name. /// /// File name to process. /// The file name without its extension. public static string RemoveExtension(this string fileName) { if (string.IsNullOrEmpty(fileName)) { return fileName; } int index = fileName.LastIndexOf('.'); return index > 0 ? fileName.Substring(0, index) : fileName; } #endregion } }