• Home
  • API Documentation
Show / Hide Table of Contents
  • Mozzarella
    • ByteArrayExtensions
      • AsString
      • ToHexString
    • CoalesceOptions
      • None
      • WhiteSpaceAsEmpty
    • EnumerableOfStringExtensions
      • Coalesce
    • ErasableString
      • Clear
      • Dispose
      • ErasableString
      • IsCleared
      • IsDisposed
      • Value
    • StringBuilderExtensions
      • Append
      • AppendIf
      • AppendJoin
      • Contains
      • IndexOf
      • LastIndexOf
      • ToLower
      • ToUpper
      • Trim
      • TrimEnd
      • TrimStart
    • StringExtensions
      • AddPrefix
      • AddSuffix
      • AfterFirst
      • AfterLast
      • BeforeFirst
      • BeforeLast
      • CICompare
      • CIContains
      • CIEquals
      • CIReplace
      • Coalesce
      • Contains
      • ContainsOnly
      • IndexOfFirstDifference
      • IsAllDigits
      • IsAlphanumeric
      • IsNullOrEmpty
      • IsNullOrWhiteSpace
      • IsOnlyAlphas
      • IsOnlyDigits
      • LevenshteinDistanceTo
      • Like
      • NullIfEmpty
      • OCICompare
      • OCIContains
      • OCIEquals
      • OCIReplace
      • OEquals
      • PascalCaseToWords
      • RemoveAllExcept
      • RemoveAllWhiteSpace
      • RemoveNonAlphanumerics
      • RemoveNonAlphas
      • Replace
      • StripNonDigits
      • StripPrefix
      • StripSuffix
      • Truncate
  • Mozzarella.Tests
    • RemoveNonAlphanumerics
      • RemoveNonAlphanumerics_DoesNotRemoveNumerics
      • RemoveNonAlphanumerics_RemovesNonAlphanumerics
      • RemoveNonAlphanumerics_ReturnsEmptyForEmpty
      • RemoveNonAlphanumerics_ReturnsNullForNull
      • RemoveNonAlphanumerics_ReturnsOriginalStringWhenNoCharactersRemoved
    • RemoveNonAlphas
      • RemoveNonAlphas_RemovesNonNumericNonAlphas
      • RemoveNonAlphas_RemovesNumerics
      • RemoveNonAlphas_ReturnsEmptyForEmpty
      • RemoveNonAlphas_ReturnsNullForNull
      • RemoveNonAlphas_ReturnsOriginalStringWhenNoCharactersRemoved

Method RemoveAllExcept

RemoveAllExcept(String, Char[])

Removes all characters that are not (latin) alphabet characters (A-Z, a-z) or numerics (0-9).

Declaration
public static string RemoveAllExcept(this string value, params char[] characters)
Parameters
Type Name Description
System.String value

The string to remove characters from.

System.Char[] characters

An enumerable of System.Char instances representing allowed characters (that will not be removed).

Returns
Type Description
System.String

Either the original string if no changes were made, or else value with all non-latin alphabet and numeric characters removed.

Remarks

Returns the original value if it is null, empty string, or does not contain any non-latin alphabet or numeric characters.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if characters is null.

RemoveAllExcept(String, IEnumerable<Char>)

Removes all characters that are not (latin) alphabet characters (A-Z, a-z) or numerics (0-9).

Declaration
public static string RemoveAllExcept(this string value, IEnumerable<char> characters)
Parameters
Type Name Description
System.String value

The string to remove characters from.

System.Collections.Generic.IEnumerable<System.Char> characters

An enumerable of System.Char instances representing allowed characters (that will not be removed).

Returns
Type Description
System.String

Either the original string if no changes were made, or else value with all non-latin alphabet and numeric characters removed.

Remarks

Returns the original value if it is null, empty string, or does not contain any non-latin alphabet or numeric characters.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if characters is null.

Back to top Copyright (c) 2017 Troy Willmot