C# Class GSF.CharExtensions

Defines extension functions related to character manipulation.
Show file Open project: GridProtectionAlliance/gsf

Public Methods

Method Description
IsAnyOf ( this value, IEnumerable testChars ) : bool

Determines if a character matches any character in a sent array.

IsInRange ( this value, char startOfRange, char endOfRange ) : bool

Tests a character to determine if it is between a specified character range

IsNumeric ( this value ) : bool

Tests a character to determine if is a common part of a numeric string (digits or one of "+ - , .")

IsWordTerminator ( this value ) : bool

Tests a character to determine if it marks the end of a typical English word.

Performs no testing for ASCII codes > 127.
Does not separate words based on punctuation of ' % - _
However does include the angle bracket symbols < > as separators

For reference the standard char tests are:

  • "IsSperator (1) == simple space (32 or 160) only.
  • IsPunctuation (23) == . , ! ? : ; " ' [ ] { } ( ) \ / @ % # * & - _ (plus other char's > 127)
  • IsSymbol (8) == $ + < > = ^ ` ~
  • IsWhiteSpace (6) == control char's 9 thru 13, plus 32 -- TAB, LF, VT, FF, CR, SP
RegexEncode ( this item ) : string

Encodes the specified Unicode character in proper Regular Expression format.

Method Details

IsAnyOf() public static method

Determines if a character matches any character in a sent array.
public static IsAnyOf ( this value, IEnumerable testChars ) : bool
value this The character to check.
testChars IEnumerable The array of characters to test.
return bool

IsInRange() public static method

Tests a character to determine if it is between a specified character range
public static IsInRange ( this value, char startOfRange, char endOfRange ) : bool
value this Input character to process.
startOfRange char Beginning of range character.
endOfRange char End of range character.
return bool

IsNumeric() public static method

Tests a character to determine if is a common part of a numeric string (digits or one of "+ - , .")
public static IsNumeric ( this value ) : bool
value this The character to check.
return bool

IsWordTerminator() public static method

Tests a character to determine if it marks the end of a typical English word.
Performs no testing for ASCII codes > 127.
Does not separate words based on punctuation of ' % - _
However does include the angle bracket symbols < > as separators

For reference the standard char tests are:
  • "IsSperator (1) == simple space (32 or 160) only.
  • IsPunctuation (23) == . , ! ? : ; " ' [ ] { } ( ) \ / @ % # * & - _ (plus other char's > 127)
  • IsSymbol (8) == $ + < > = ^ ` ~
  • IsWhiteSpace (6) == control char's 9 thru 13, plus 32 -- TAB, LF, VT, FF, CR, SP
public static IsWordTerminator ( this value ) : bool
value this Input character to check.
return bool

RegexEncode() public static method

Encodes the specified Unicode character in proper Regular Expression format.
public static RegexEncode ( this item ) : string
item this Unicode character to encode in Regular Expression format.
return string