StringsHelper Module¶
Common string utilities and algorithms wrapped in a helper class.
- class HMB.StringsHelper.StringsHelper(string)[source]¶
Bases:
objectStringsHelper: Helper methods for common string operations.
Initialize with a string and call instance methods to perform queries and small algorithms (permutations, compression, palindrome-permutation checks, etc.). All public methods are designed to be small, self-contained, and documented inline.
Constructor for the StringsHelper class.
- Parameters:
string (str) – The string to be used by the class.
- __init__(string)[source]¶
Constructor for the StringsHelper class.
- Parameters:
string (str) – The string to be used by the class.
- GetString()[source]¶
Returns the string that was set during creating the object.
- Returns:
The string that was set during creating the object.
- Return type:
- GetStringLength()[source]¶
Returns the length of the string that was set during creating the object.
- Returns:
The length of the string that was set during creating the object.
- Return type:
- SetString(string)[source]¶
Sets the string to a new value.
- Parameters:
string (str) – The new value for the string.
- GetCharCount(char)[source]¶
Returns the number of times the specified character appears in the string.
- GetCharCountFrom(char, index)[source]¶
Returns the number of times the specified character appears in the string
- GetCharCountTo(char, index)[source]¶
Returns the number of times the specified character appears in the string
- GetCharCountBetween(char, index1, index2)[source]¶
Returns the number of times the specified character appears in the string
- GetCharCountBetweenInclusive(char, index1, index2)[source]¶
Returns the number of times the specified character appears in the string
- GetCharCountBetweenExclusive(char, index1, index2)[source]¶
Returns the number of times the specified character appears in the string
- GetReverse()[source]¶
Returns the reverse of the string.
- Returns:
The reverse of the string.
- Return type:
- GetReverseBetween(index1, index2)[source]¶
Returns the reverse of the string between the specified indexes.
- GetReverseBetweenInclusive(index1, index2)[source]¶
Returns the reverse of the string between the specified indexes.
- GetReverseBetweenExclusive(index1, index2)[source]¶
Returns the reverse of the string between the specified indexes.
- IsSubStringFrom(string)[source]¶
Returns True if the string is a substring of the string that was set during creating the object.
- IsSubStringTo(string)[source]¶
Returns True if the string is a substring of the string that was set during creating the object.
- IsRotationWith(string)[source]¶
Returns True if the string is a rotation of the string that was set during creating the object.
- GetPermutations()[source]¶
Returns a list of all the permutations of the string that was set during creating the object.
- Returns:
A list of all the permutations of the string that was set during creating the object.
- Return type:
- IsPermutationOf(string)[source]¶
Returns True if the string is a permutation of the string that was set during creating the object.
- IsPalindromePermutation()[source]¶
Returns True if the string is a palindrome permutation of the string that was set during creating the object.
- Returns:
True if the string is a palindrome permutation of the string that was set during creating the object.
- Return type:
- IsUniqueCharacters()[source]¶
Returns True if the string has all unique characters.
- Returns:
True if the string has all unique characters.
- Return type: