Пример #1
0
        public static String Unformat(this String str, UnformatOptions options)
        {
            var stringBuilder = new StringBuilder();

            switch (options)
            {
            case UnformatOptions.DigitsOnly:
                foreach (char c in str.Where(e => Char.IsDigit(e)))
                {
                    stringBuilder.Append(c);
                }
                break;

            case UnformatOptions.LettersOnly:
                foreach (char c in str.Where(e => Char.IsLetter(e)))
                {
                    stringBuilder.Append(c);
                }
                break;

            case UnformatOptions.DigitsAndLettersOnly:
                foreach (char c in str.Where(e => Char.IsLetterOrDigit(e)))
                {
                    stringBuilder.Append(c);
                }
                break;
            }

            return(stringBuilder.ToString());
        }
Пример #2
0
        public static String Unformat(this String str, UnformatOptions options)
        {
            var stringBuilder = new StringBuilder();

            switch (options)
            {
                case UnformatOptions.DigitsOnly:
                    foreach (char c in str.Where(e => Char.IsDigit(e)))
                    {
                        stringBuilder.Append(c);
                    }
                    break;
                case UnformatOptions.LettersOnly:
                    foreach (char c in str.Where(e => Char.IsLetter(e)))
                    {
                        stringBuilder.Append(c);
                    }
                    break;
                case UnformatOptions.DigitsAndLettersOnly:
                    foreach (char c in str.Where(e => Char.IsLetterOrDigit(e)))
                    {
                        stringBuilder.Append(c);
                    }
                    break;
            }

            return stringBuilder.ToString();
        }