Class ExtString
Adds extension methods for System.String.
public static class ExtString
Remarks
Some .NET System.String methods use System.StringComparison.CurrentCulture by default, while others use ordinal or invariant comparison. It is confusing (difficult to remember), dangerous (easy to make bugs), slower and rarely useful. Microsoft recommends to specify StringComparison.Ordinal[IgnoreCase] explicitly. See https://msdn.microsoft.com/en-us/library/ms973919.aspx. This class adds ordinal comparison versions of these methods. Same or similar name, for example Ends for EndsWith. See also process.thisProcessCultureIsInvariant.
This class also adds more methods. You also can find string functions in other classes of this library, including StringUtil, regexp, pathname, csvTable, keys.more, Convert2, Hash.
Namespace: Au.Types
Assembly: Au.dll
Methods
Name | Description |
---|---|
Ends(ReadOnlySpan<char>, ReadOnlySpan<char>, bool) | Returns |
Ends(string, bool, params ReadOnlySpan<string>) | Compares end of this string with multiple strings. Returns 1-based index of the matching string, or 0 if none. |
Ends(string, char) | Returns |
Ends(string, ReadOnlySpan<char>, bool) | Compares end of this string with other string. Returns |
Eq(ReadOnlySpan<char>, int, char) | Returns |
Eq(ReadOnlySpan<char>, int, ReadOnlySpan<char>, bool) | Compares part of this span with string s. Returns |
Eq(ReadOnlySpan<char>, ReadOnlySpan<char>) | Returns |
Eq(string, bool, params ReadOnlySpan<string>) | Compares this strings with multiple strings. Returns 1-based index of the matching string, or 0 if none. |
Eq(string, int, bool, params ReadOnlySpan<string>) | Compares part of this string with multiple strings. Returns 1-based index of the matching string, or 0 if none. |
Eq(string, int, char) | Returns |
Eq(string, int, ReadOnlySpan<char>, bool) | Compares part of this string with other string. Returns |
Eq(string, Range, ReadOnlySpan<char>, bool) | Compares part of this string with other string. Returns |
Eq(string, string, bool) | Compares this and other string. Returns |
Eqi(ReadOnlySpan<char>, ReadOnlySpan<char>) | Returns |
Eqi(string, string) | Compares this and other string ignoring case (case-insensitive). Returns |
Escape(string, int, bool) | Replaces unsafe characters with C# escape sequences. If the string contains these characters, replaces and returns new string. Else returns this string. |
Find(string, string, bool) | Finds substring in this string. Returns its 0-based index, or -1 if not found. |
Find(string, string, int, bool) | Finds substring in part of this string. Returns its 0-based index, or -1 if not found. |
Find(string, string, Range, bool) | Finds substring in part of this string. Returns its 0-based index, or -1 if not found. |
FindAny(string, string, Range?) | Finds the first character specified in chars. Returns its index, or -1 if not found. |
FindLastAny(string, string, Range?) | Finds the last character specified in chars (searches right to left). Returns its index, or -1 if not found. |
FindLastNot(string, string, Range?) | Finds the last character not specified in chars (searches right to left). Returns its index, or -1 if not found. |
FindNot(string, string, Range?) | Finds the first character not specified in chars. Returns its index, or -1 if not found. |
FindWord(string, string, Range?, bool, string, Func<char, bool>) | Finds whole word. Returns its 0-based index, or -1 if not found. |
IndexOf(ReadOnlySpan<char>, int, char) | Finds character c in this span, starting from index. |
IndexOf(ReadOnlySpan<char>, int, ReadOnlySpan<char>, bool) | Finds string s in this span, starting from index. |
IndexOf(ReadOnlySpan<char>, Range, char) | Finds character c in range of this span. |
IndexOf(ReadOnlySpan<char>, Range, ReadOnlySpan<char>, bool) | Finds string s in range of this span. |
IndexOfNot(ReadOnlySpan<char>, string) | Finds the first character not specified in chars. Returns its index, or -1 if not found. |
Insert(string, Index, string) | Inserts other string. |
IsAscii(ReadOnlySpan<byte>) | Returns |
IsAscii(ReadOnlySpan<char>) | Returns |
IsAscii(string) | Returns |
LastIndexOfNot(ReadOnlySpan<char>, string) | Finds the last character not specified in chars. Returns its index, or -1 if not found. |
Lenn(string) | Returns System.String.Length. Returns 0 if this string is |
Like(ReadOnlySpan<char>, string, bool) | Compares this string with a string that possibly contains wildcard characters.
Returns |
Like(string, bool, params ReadOnlySpan<string>) | Calls Like(string, string, bool) for each wildcard pattern specified in the argument list until it returns |
Like(string, string, bool) | Compares this string with a string that possibly contains wildcard characters.
Returns |
Limit(string, int, bool, bool) | If this string is longer than limit, returns its substring 0 to limit-1 with appended |
LineCount(ReadOnlySpan<char>, bool, bool) | Returns the number of lines. |
LineCount(string, bool, Range?, bool) | Returns the number of lines. |
Lines(ReadOnlySpan<char>, bool, bool, bool) | Splits this string into lines as start/end offsets. |
Lines(string, bool, bool, bool) | Splits this string into lines. |
Lines(string, Range, bool, bool, bool) | Splits this string or a range in it into lines as start/end offsets. |
Lower(string) | Converts this string to lower case. |
NE(string) | Returns |
Remove(string, Range) | Removes part of this string. |
RemoveSuffix(string, char) | Removes suffix character from the end. |
RemoveSuffix(string, string, bool) | Removes suffix string from the end. |
ReplaceAt(string, int, int, string) | Replaces part of this string with other string. |
ReplaceAt(string, Range, string) | Replaces part of this string with other string. |
ReverseString(string, bool) | Reverses this string, like |
RxFindAll(string, string, RXFlags, Range?) | Finds all match instances of PCRE regular expression rx. |
RxFindAll(string, string, out RXMatch[], RXFlags, Range?) | Finds all match instances of PCRE regular expression rx. Gets array of RXMatch. |
RxFindAll(string, string, int, RXFlags, Range?) | Finds all match instances of PCRE regular expression rx. |
RxFindAll(string, string, int, out string[], RXFlags, Range?) | Finds all match instances of PCRE regular expression rx. Gets array of strings. |
RxIsMatch(string, string, RXFlags, Range?) | Returns |
RxMatch(string, string, out RXMatch, RXFlags, Range?) | Returns |
RxMatch(string, string, int, out RXGroup, RXFlags, Range?) | Returns |
RxMatch(string, string, int, out string, RXFlags, Range?) | Returns |
RxReplace(string, string, Func<RXMatch, string>, int, RXFlags, Range?) | Finds and replaces all match instances of PCRE regular expression rx. Uses a callback function. |
RxReplace(string, string, Func<RXMatch, string>, out string, int, RXFlags, Range?) | Finds and replaces all match instances of PCRE regular expression rx. Uses a callback function. |
RxReplace(string, string, string, int, RXFlags, Range?) | Finds and replaces all match instances of PCRE regular expression rx. |
RxReplace(string, string, string, out string, int, RXFlags, Range?) | Finds and replaces all match instances of PCRE regular expression rx. |
RxSplit(string, string, int, RXFlags, Range?) | Returns an array of substrings that in this string are delimited by regular expression matches. |
Split(ReadOnlySpan<char>, char, StringSplitOptions) | Splits this string span into substrings as start/end offsets. |
Split(ReadOnlySpan<char>, string, StringSplitOptions) | Splits this string span into substrings as start/end offsets. |
Split(string, Range, char, StringSplitOptions) | Splits this string into substrings as start/end offsets. |
Split(string, Range, string, StringSplitOptions) | Splits this string into substrings as start/end offsets. |
Split(string, Range, StringSplitOptions, ReadOnlySpan<char>) | Splits this string into substrings as start/end offsets. Can be used multiple separators. |
Split(string, Range, StringSplitOptions, ReadOnlySpan<string>) | Splits this string into substrings as start/end offsets. Can be used multiple separators. |
SplitAny(ReadOnlySpan<char>, ReadOnlySpan<char>, StringSplitOptions) | Splits this string span into substrings as start/end offsets. Can be used multiple separators. |
SplitAny(ReadOnlySpan<char>, ReadOnlySpan<string>, StringSplitOptions) | Splits this string span into substrings as start/end offsets. Can be used multiple separators. |
SplitAnyS(ReadOnlySpan<char>, ReadOnlySpan<char>, StringSplitOptions) | Splits this string span into substrings. Can be used multiple separators. |
SplitAnyS(ReadOnlySpan<char>, ReadOnlySpan<string>, StringSplitOptions) | Splits this string span into substrings. Can be used multiple separators. |
SplitS(ReadOnlySpan<char>, char, StringSplitOptions) | Splits this string span into substrings. |
SplitS(ReadOnlySpan<char>, string, StringSplitOptions) | Splits this string span into substrings. |
Starts(ReadOnlySpan<char>, ReadOnlySpan<char>, bool) | Returns |
Starts(string, bool, params ReadOnlySpan<string>) | Compares beginning of this string with multiple strings. Returns 1-based index of the matching string, or 0 if none. |
Starts(string, char) | Returns |
Starts(string, ReadOnlySpan<char>, bool) | Compares beginning of this string with other string. Returns |
ToInt(string, int, STIFlags) | Converts part of this string to int number. |
ToInt(string, int, out int, STIFlags) | Converts part of this string to int number and gets the number end index. |
ToInt(string, out int, int, STIFlags) | Converts part of this string to int number. |
ToInt(string, out int, int, out int, STIFlags) | Converts part of this string to int number and gets the number end index. |
ToInt(string, out long, int, STIFlags) | Converts part of this string to long number. |
ToInt(string, out long, int, out int, STIFlags) | Converts part of this string to long number and gets the number end index. |
ToInt(string, out uint, int, STIFlags) | Converts part of this string to uint number. |
ToInt(string, out uint, int, out int, STIFlags) | Converts part of this string to uint number and gets the number end index. |
ToInt(string, out ulong, int, STIFlags) | Converts part of this string to ulong number. |
ToInt(string, out ulong, int, out int, STIFlags) | Converts part of this string to ulong number and gets the number end index. |
ToNumber(string, out double, Range?, NumberStyles) | Converts this string or its part to double number. |
ToNumber(string, out int, Range?, NumberStyles) | Converts this string or its part to int number. |
ToNumber(string, out long, Range?, NumberStyles) | Converts this string or its part to long number. |
ToNumber(string, Range?, NumberStyles) | Converts this string or its part to double number. |
ToNumber(string, out float, Range?, NumberStyles) | Converts this string or its part to float number. |
ToNumber(string, out uint, Range?, NumberStyles) | Converts this string or its part to uint number. |
ToNumber(string, out ulong, Range?, NumberStyles) | Converts this string or its part to ulong number. |
ToStringUTF8(byte[]) | Converts UTF-8 string to string. |
ToStringUTF8(ReadOnlySpan<byte>) | Converts UTF-8 string to string. |
ToStringUTF8(Span<byte>) | Converts UTF-8 string to string. |
ToUTF8(ReadOnlySpan<char>, bool) | Converts to UTF-8. |
ToUTF8(Span<char>, bool) | Converts to UTF-8. |
ToUTF8(string) | Converts to UTF-8 ( |
Trim(string, string) | Removes specified characters from the start and end of this string. |
TrimEnd(string, string) | Removes specified characters from the end of this string. |
TrimStart(string, string) | Removes specified characters from the start of this string. |
Unescape(string) | Replaces C# escape sequences to characters in this string. |
Unescape(string, out string) | Replaces C# escape sequences to characters in this string. |
Upper(string) | Converts this string to upper case. |
Upper(string, SUpper, CultureInfo) | Converts this string or only the first character to upper case or all words to title case. |