Table of Contents

Class StringUtility

Namespace
Uncreated.Warfare.Util
Assembly
Uncreated.Warfare.dll
public static class StringUtility
Inheritance
StringUtility
Inherited Members

Methods

LevenshteinDistance(char*, int, char*, int, CultureInfo, LevenshteinOptions)

Computes the number of edits required to turn one string to another.

public static int LevenshteinDistance(char* a, int aChars, char* b, int bChars, CultureInfo formatProvider, LevenshteinOptions options = (LevenshteinOptions)0)

Parameters

a char*
aChars int
b char*
bChars int
formatProvider CultureInfo
options LevenshteinOptions

Returns

int

Remarks

LevenshteinDistance(ReadOnlySpan<char>, ReadOnlySpan<char>, CultureInfo, LevenshteinOptions)

Computes the number of edits required to turn one string to another.

public static int LevenshteinDistance(ReadOnlySpan<char> a, ReadOnlySpan<char> b, CultureInfo formatProvider, LevenshteinOptions options = (LevenshteinOptions)0)

Parameters

a ReadOnlySpan<char>
b ReadOnlySpan<char>
formatProvider CultureInfo
options LevenshteinOptions

Returns

int

Remarks

LevenshteinDistance(string, string, CultureInfo, LevenshteinOptions)

Computes the number of edits required to turn one string to another.

public static int LevenshteinDistance(string a, string b, CultureInfo formatProvider, LevenshteinOptions options = (LevenshteinOptions)0)

Parameters

a string
b string
formatProvider CultureInfo
options LevenshteinOptions

Returns

int

Remarks

Exceptions

ArgumentNullException

RemoveMany(ReadOnlySpan<char>, bool, params ReadOnlySpan<char>)

Remove any occurances of any character in replaceables from source and return it as a string.

public static string RemoveMany(ReadOnlySpan<char> source, bool caseSensitive, params ReadOnlySpan<char> replaceables)

Parameters

source ReadOnlySpan<char>
caseSensitive bool
replaceables ReadOnlySpan<char>

Returns

string

RemoveMany(string?, bool, params ReadOnlySpan<char>)

Remove any occurances of any character in replaceables from source and return it as a string.

public static string? RemoveMany(string? source, bool caseSensitive, params ReadOnlySpan<char> replaceables)

Parameters

source string
caseSensitive bool
replaceables ReadOnlySpan<char>

Returns

string

Remarks

If source is null, it will just return null.

Truncate(string?, int)

Truncates a string if it's over a certain length.

public static string? Truncate(this string? str, int length)

Parameters

str string
length int

Returns

string

TruncateUtf8Bytes(ReadOnlySpan<char>, int, out int)

Truncates text so that it's UTF-8 byte count is less than or equal to maximumBytes.

public static ReadOnlySpan<char> TruncateUtf8Bytes(ReadOnlySpan<char> text, int maximumBytes, out int byteLength)

Parameters

text ReadOnlySpan<char>
maximumBytes int
byteLength int

The length in UTF-8 bytes of the truncated text.

Returns

ReadOnlySpan<char>

TruncateWithEllipses(string?, int)

Truncates a string if it's over a certain length.

public static string? TruncateWithEllipses(this string? str, int length)

Parameters

str string
length int

Returns

string