Selector - IvanStoychev/IvanStoychev.Useful.String.Extensions Wiki

This is a list of all methods in the "Selector" class. The class isn't actually accessible from the NuGet package but it is used to logically separate methods for better organization.


SubstringStart (string endString, bool inclusive = false, StringComparison stringComparison = StringComparison.CurrentCulture)

Introduced in version 1.0.0

Returns everything from the start of the original string to the first occurrence of the given endString.

Example:

string exampleString = "From start to the finish of the finish line."
string endString = "finish";
string substring = exampleString.SubstringStart(endString);

// The variable "substring" will have the value "From start to the ".

SubstringStartLast (string endString, bool inclusive = false, StringComparison stringComparison = StringComparison.CurrentCulture)

Introduced in version 1.0.0

Returns everything from the start of the original string to the last occurrence of the given endString.

Example:

string exampleString = "From start to the finish of the finish line."
string endString = "finish";
string substring = exampleString.SubstringStart(endString);

// The variable "substring" will have the value "From start to the finish of the ".

Substring (string startString, int length, bool inclusive = false, StringComparison stringComparison = StringComparison.CurrentCulture)

Introduced in version 1.0.0

Returns a length of characters from the end of the first occurrence of the given startString. The returned value can contain startString if inclusive is "true".

An ArgumentOutOfRangeException exception will be thrown if the given length is bigger than the amount of remaining characters from the end of the first occurrence of the given startString to the end of the original string. I.e. "asd123asd456".Substring("asd, 23") will throw an exception because there are only 9 characters ("123asd456") left after the first "asd" but the method requested 23. If you want to select everything from a given substring to the end of the original instance use the SubstringEnd (string startString, bool inclusive = false, StringComparison stringComparison = StringComparison.CurrentCulture) method.

Substring (string startString, string endString, StringInclusionOptions stringInclusionOptions = StringInclusionOptions.IncludeNone, StringComparison stringComparison = StringComparison.CurrentCulture)

Introduced in version 1.0.0

Returns everything between the first occurrences of startString and endString. Whether startString and/or endString, themselves, are returned is controlled by the stringInclusionOptions argument.

SubstringLast (string startString, string endString, StringInclusionOptions stringInclusionOptions = StringInclusionOptions.IncludeNone, StringComparison stringComparison = StringComparison.CurrentCulture)

Introduced in version 1.0.0

Returns everything between the first occurrence of startString and the last occurrence of endString. Whether startString and/or endString, themselves, are returned is controlled by the stringInclusionOptions argument.

SubstringEnd (string startString, bool inclusive = false, StringComparison stringComparison = StringComparison.CurrentCulture)

Introduced in version 1.0.0

Returns everything from the first occurrence of the given endString to the end of the original string.

SubstringEndLast (string startString, bool inclusive = false, StringComparison stringComparison = StringComparison.CurrentCulture)

Introduced in version 1.0.0

Returns everything from the last occurrence of the given endString to the end of the original string.

SubstringEndLast (string startString, int length, bool inclusive = false, StringComparison stringComparison = StringComparison.CurrentCulture)

Introduced in version 1.0.0

Returns a length of characters from the end of the last occurrence of the given startString. The returned value can contain startString if inclusive is "true".

An ArgumentOutOfRangeException exception will be thrown if the given length is bigger than the amount of remaining characters from the end of the last occurrence of the given startString to the end of the original string. I.e. "asd123asd456".SubstringEndLast("asd, 23") will throw an exception because there are only 3 characters ("456") left after the last "asd" but the method requested 23. If you want to select everything from the last occurrence of a given substring to the end of the original instance use the SubstringEndLast (string startString, bool inclusive = false, StringComparison stringComparison = StringComparison.CurrentCulture)