Class SHParts
- Namespace
- SunamoStringParts
- Assembly
- SunamoStringParts.dll
Provides methods for removing or keeping parts of a string based on delimiter positions.
public class SHParts
- Inheritance
-
SHParts
- Inherited Members
- Extension Methods
Methods
KeepAfterFirst(string, string, bool)
Keeps only the part of the string after the first occurrence of the specified delimiter.
public static string KeepAfterFirst(string text, string delimiter, bool isKeepingDelimiter = false)
Parameters
textstringThe input string to process.
delimiterstringThe delimiter to search for.
isKeepingDelimiterboolIf true, the delimiter is prepended to the result.
Returns
- string
The substring after the first occurrence of the delimiter, or the original string if not found.
KeepAfterLast(string, string)
Keeps only the part of the string after the last occurrence of the specified delimiter.
public static string KeepAfterLast(string text, string delimiter)
Parameters
Returns
- string
The substring after the last occurrence of the delimiter, or the original string if not found.
RemoveAfterFirst(string, char)
Removes everything after the first occurrence of the specified character delimiter.
public static string RemoveAfterFirst(string text, char delimiter)
Parameters
Returns
- string
The substring before the first occurrence of the delimiter, or the original string if not found.
RemoveAfterFirst(string, string)
Removes everything after the first occurrence of the specified string delimiter (including the delimiter itself).
public static string RemoveAfterFirst(string text, string delimiter)
Parameters
Returns
- string
The substring before the first occurrence of the delimiter, or the original string if not found.
RemoveAfterFirstChar(string, char)
Removes everything after the first occurrence of the specified character delimiter.
public static string RemoveAfterFirstChar(string text, char delimiter)
Parameters
Returns
- string
The substring before the first occurrence of the delimiter.
RemoveAfterFirstFunc(string, Func<char, bool>, params char[])
Removes everything after the first character matching the predicate, unless that character is in the allowed list.
public static string RemoveAfterFirstFunc(string text, Func<char, bool> predicate, params char[] allowedCharacters)
Parameters
textstringThe input string to process.
predicateFunc<char, bool>A function that determines whether a character should trigger removal.
allowedCharacterschar[]Characters that are allowed even if they match the predicate.
Returns
- string
The substring before the first matching character, or the original string if no match is found.
RemoveAfterLast(string, object)
Removes everything after the last occurrence of delimiter (including the delimiter itself).
The text parameter must be first due to ChangeContent usage.
public static string RemoveAfterLast(string text, object delimiter)
Parameters
Returns
- string
The substring before the last occurrence of the delimiter, or the original string if not found.