Click or drag to resize

StringAlgorithms Class

Utility class with various string algorithms.
Inheritance Hierarchy
SystemObject
  DHI.Mike1D.GenericStringAlgorithms

Namespace:  DHI.Mike1D.Generic
Assembly:  DHI.Mike1D.Generic (in DHI.Mike1D.Generic.dll) Version: 19.0.0.0 (11.1.1.1111)
Syntax
public static class StringAlgorithms

The StringAlgorithms type exposes the following members.

Methods
  NameDescription
Public methodStatic memberCode exampleCharactersInOrder Obsolete.
Checks if the characters of one of the strings occur in order in the other string. Returns the number of characters in the two strings that match in order. The value will be between 0 and the size of the smallest string.

Examples
The following strings match, since the one fully contains the other in order
CharactersInOrder("BLUB","aBcLeUgBh") = 4
CharactersInOrder("aBcLeUgBh","BLUB") = 4
The following strings differ by one, since the final B is missing in the long string
CharactersInOrder("BLUB","aBcLeUg") = 3
CharactersInOrder("aBcLeUg","BLUB") = 3
Public methodStatic memberCount
Count the number of occurances of c in the string source.
Public methodStatic memberJoinQuoted(Char, Char, IEnumerableString)
Concatenates the members of a collection, using the specified separator between each member, and surrounding each non-null member by the specified quote char.
Public methodStatic memberJoinQuoted(StringBuilder, Char, Char, IEnumerableString)
Concatenates the members of a collection, using the specified separator between each member, and surrounding each non-null member by the specified quote char, appending to StringBuilder
Public methodStatic memberLevenshteinDistance
Calculate the Levenshtein distance between two strings, i.e. the minimum number of edits in order to make the two strings equal
Public methodStatic memberLevenshteinDistanceRef
Calculate the Levenshtein distance between two strings, i.e. the minimum number of edits in order to make the two strings equal

Reference implementation that stores the entire distance matrix

Public methodStatic memberCode exampleLongestCommonSubsequence
Calculate the Longest Common Subsequence.

It differs from problems of finding common substrings: unlike substrings, subsequences are not required to occupy consecutive positions within the original sequences.

Examples
The following strings match, since the one fully contains the other in order
LongestCommonSubsequence("BLUB","aBcLeUgBh") = 4
LongestCommonSubsequence("aBcLeUgBh","BLUB") = 4
The following strings differ by one, since the final B is missing in the long string
LongestCommonSubsequence("BLUB","aBcLeUg") = 3
LongestCommonSubsequence("aBcLeUg","BLUB") = 3
Public methodStatic memberSplitQuoted
Method to split a string that may contain quote characters for substrings.
Top
See Also