StringAlgorithms Class

Utility class with various string algorithms.

Definition

Namespace: DHI.Mike1D.Generic
Assembly: DHI.Mike1D.Generic (in DHI.Mike1D.Generic.dll) Version: 24.0.0.0 (11.1.1.1111)
C#
public static class StringAlgorithms
Inheritance
Object    StringAlgorithms

Methods

CharactersInOrder 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.

Example

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

Obsolete
Count Count the number of occurances of c in the string source.
JoinQuoted(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.
JoinQuoted(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
LevenshteinDistance(String, String) Calculate the Levenshtein distance between two strings, i.e. the minimum number of edits in order to make the two strings equal
LevenshteinDistance(String, String, Boolean) Calculate the Levenshtein distance between two strings, i.e. the minimum number of edits in order to make the two strings equal
LevenshteinDistanceRef 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

LongestCommonSubsequence 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.

Example

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
SplitQuoted Method to split a string that may contain quote characters for substrings.

See Also