Table of Contents

Class SH

Namespace
SunamoString
Assembly
SunamoString.dll

Provides string helper methods for various text operations.

public class SH
Inheritance
SH
Inherited Members
Extension Methods

Fields

BracketsLeft

Mapping of bracket types to their left characters.

protected static Dictionary<Brackets, char> BracketsLeft

Field Value

Dictionary<Brackets, char>

BracketsRight

Mapping of bracket types to their right characters.

protected static Dictionary<Brackets, char> BracketsRight

Field Value

Dictionary<Brackets, char>

IsCzechCulture

Indicates whether the current UI culture is Czech.

protected static bool IsCzechCulture

Field Value

bool

XMismatchCountInInputArraysOfSHAllHaveRightFormat

Exception message constant.

public static string XMismatchCountInInputArraysOfSHAllHaveRightFormat

Field Value

string

Properties

BracketsLeftList

List of left bracket characters.

protected static List<char> BracketsLeftList { get; set; }

Property Value

List<char>

BracketsRightList

List of right bracket characters.

protected static List<char> BracketsRightList { get; set; }

Property Value

List<char>

Methods

AddBeforeUpperChars(string, char, bool)

Adds specified content to the string.

public static string AddBeforeUpperChars(string input, char add, bool preserveAcronyms)

Parameters

input string
add char
preserveAcronyms bool

Returns

string

AddEmptyLines(string, int)

Adds specified content to the string.

public static string AddEmptyLines(string content, int addRowsDuringScrolling)

Parameters

content string
addRowsDuringScrolling int

Returns

string

AddIfNotContains(string, string, string?)

Appends the text to add if the source text does not already contain it. Optionally performs case-insensitive comparison.

public static string AddIfNotContains(string text, string textToAdd, string? lowerCaseVersion = null)

Parameters

text string

The source text to check and possibly append to.

textToAdd string

The text to append if not already present.

lowerCaseVersion string

If provided, comparison is done in lowercase using this value.

Returns

string

AddSpaceAfterFirstLetterForEveryAndSort(List<string>)

Add Space After First Letter For Every And Sort operation on the input.

public static List<string> AddSpaceAfterFirstLetterForEveryAndSort(List<string> input)

Parameters

input List<string>

Returns

List<string>

AddSpaceAndDontDuplicate(bool, string, string)

Adds specified content to the string.

public static string AddSpaceAndDontDuplicate(bool after, string text, string colon)

Parameters

after bool
text string
colon string

Returns

string

AllBrackets(string)

Returns a list of all bracket characters found in the text.

public static List<char> AllBrackets(string text)

Parameters

text string

The text to scan for bracket characters.

Returns

List<char>

AnotherOtherThanLetterOrDigit(string, int)

Finds the next non-letter-or-digit character from the start index.

public static int AnotherOtherThanLetterOrDigit(string text, int startIndex)

Parameters

text string
startIndex int

Returns

int

AppendIfDontEndingWith(string, string)

public static string AppendIfDontEndingWith(string text, string append)

Parameters

text string
append string

Returns

string

ChangeEncodingProcessWrongCharacters(ref string)

Changes encoding or format of the string.

public static bool ChangeEncodingProcessWrongCharacters(ref string input)

Parameters

input string

Returns

bool

ChangeEncodingProcessWrongCharacters(ref string, Encoding)

When a file contains garbled text, read via File.ReadAllText, then convert via SH.ChangeEncodingProcessWrongCharacters. If none of the encodings produce meaningful text, the file is hopelessly corrupted. Otherwise, 10 encodings should be sufficient.

public static bool ChangeEncodingProcessWrongCharacters(ref string input, Encoding oldEncoding)

Parameters

input string

The input string with potentially wrong encoding.

oldEncoding Encoding

The original encoding to convert from.

Returns

bool

CharsBeforeAndAfter(string, string, int, int, int)

A2 is use to calculate length of center

public static string CharsBeforeAndAfter(string text, string centerString, int centerIndex, int before, int after)

Parameters

text string

The source text to extract characters from.

centerString string

The center string around which to extract characters.

centerIndex int

The index of the center string in the source text.

before int

The number of characters to extract before the center.

after int

The number of characters to extract after the center.

Returns

string

CheckWhetherNoBrackedIsBeforeOther1(string)

Checks whether all brackets in the text are balanced using a stack-based approach.

public static bool CheckWhetherNoBrackedIsBeforeOther1(string text)

Parameters

text string

The text containing brackets to validate.

Returns

bool

CheckWhetherNoBrackedIsBeforeOther2(string)

Checks whether all brackets in the text are balanced and none is opened before the previous one is closed. Uses AllBrackets and BalancedBrackets helper.

public static bool CheckWhetherNoBrackedIsBeforeOther2(string text)

Parameters

text string

The text containing brackets to validate.

Returns

bool

ClosingBracketFor(char)

Gets the closing bracket character for the given opening bracket.

public static char ClosingBracketFor(char openingBracket)

Parameters

openingBracket char

Returns

char

CompareStringIgnoreWhitespaces(string, string)

Compares strings ignoring whitespace differences.

public static bool CompareStringIgnoreWhitespaces(string firstText, string secondText)

Parameters

firstText string
secondText string

Returns

bool

CompareStringIgnoreWhitespaces2(string, string)

Compares strings ignoring whitespace differences.

public static bool CompareStringIgnoreWhitespaces2(string firstText, string secondText)

Parameters

firstText string
secondText string

Returns

bool

ConcatIfBeforeHasValue(params string[])

Concatenates pairs of strings where even-indexed elements are checked for content. Must have an even number of elements. If even element [0], [2], ... has at least one non-whitespace character, the even and odd pair are appended together. Otherwise the pair is skipped.

public static string ConcatIfBeforeHasValue(params string[] array)

Parameters

array string[]

The pairs of strings to conditionally concatenate.

Returns

string

ConcatSpace(IList)

Concatenates all elements of the list separated by spaces.

public static string ConcatSpace(IList list)

Parameters

list IList

The list of elements to concatenate with spaces.

Returns

string

Contains(string, string, SearchStrategy)

AnySpaces - split A2 by spaces and A1 must contains all parts ExactlyName - == FixedSpace - simple contains A1 = search for exact occur. otherwise split both to words Control for string.Empty, because otherwise all results are true

public static bool Contains(string input, string term, SearchStrategy searchStrategy = SearchStrategy.FixedSpace)

Parameters

input string

The text to search in.

term string

The term to search for.

searchStrategy SearchStrategy

The search strategy to use.

Returns

bool

Contains(string, string, SearchStrategy, bool)

AnySpaces - split A2 by spaces and A1 must contains all parts ExactlyName - == FixedSpace - simple contains

public static bool Contains(string input, string term, SearchStrategy searchStrategy, bool caseSensitive)

Parameters

input string

The text to search in.

term string

The term to search for.

searchStrategy SearchStrategy

The search strategy to use.

caseSensitive bool

Whether the comparison is case-sensitive.

Returns

bool

ContainsAll(string, IList<string>, ContainsCompareMethodString)

Return whether A1 contains all from A2

public static bool ContainsAll(string input, IList<string> allWords, ContainsCompareMethodString ccm = ContainsCompareMethodString.WholeInput)

Parameters

input string

The text to search in.

allWords IList<string>

The list of words that must all be contained.

ccm ContainsCompareMethodString

The comparison method to use.

Returns

bool

ContainsAny(string, bool, IList<string>)

Usage: Exceptions.ArrayElementContainsUnallowedStrings Return which a3 is contained in A1. if a2 and A3 contains only 1 element, check for contains these first element If A3 contains more than 1 element, A2 is not used If contains more elements, wasnts check Return elements from A3 which is contained If don't contains, return zero element collection

public static List<string> ContainsAny(string text, bool isCheckingCaseForSingleString, IList<string> contains)

Parameters

text string

The text to search in.

isCheckingCaseForSingleString bool

Whether to perform a case check when only one string is in the list.

contains IList<string>

The list of substrings to search for.

Returns

List<string>

ContainsAnyBool(string, bool, IList<string>)

Returns whether the text contains any of the specified substrings.

public static bool ContainsAnyBool(string text, bool isCheckingInCaseOnlyOneString, IList<string> contains)

Parameters

text string

The text to search in.

isCheckingInCaseOnlyOneString bool

Whether to perform a case check when only one string is in the list.

contains IList<string>

The list of substrings to search for.

Returns

bool

ContainsAnyChar(string, bool, IList<char>)

Contains Any Char operation on the input.

public static List<char> ContainsAnyChar(string text, bool isCheckingCaseForSingleString, IList<char> contains)

Parameters

text string
isCheckingCaseForSingleString bool
contains IList<char>

Returns

List<char>

ContainsAnyFromElement(StringBuilder, IList<string>)

Returns the indexes of elements from the list that are contained in the StringBuilder content.

public static List<int> ContainsAnyFromElement(StringBuilder stringBuilder, IList<string> list)

Parameters

stringBuilder StringBuilder

The StringBuilder whose content is searched.

list IList<string>

The list of strings to search for.

Returns

List<int>

ContainsAny<T>(bool, T, IList<T>)

public static List<T> ContainsAny<T>(bool isCheckingCaseForSingleString, T value, IList<T> contains)

Parameters

isCheckingCaseForSingleString bool

Whether to perform a case check when only one string is in the list.

value T

The value to check against.

contains IList<T>

The list of values to search for.

Returns

List<T>

Type Parameters

T

Exceptions

NotImplementedException

ContainsAtLeastOne(string, List<string>)

Returns true if the text contains at least one element from the list.

public static bool ContainsAtLeastOne(string text, List<string> list)

Parameters

text string

The text to search in.

list List<string>

The list of substrings to search for.

Returns

bool

ContainsBoolBool(string, string, bool, bool)

FixedSpace - Contains AnySpaces - split input by spaces and A1 must contains all parts ExactlyName - Is exactly the same

public static bool ContainsBoolBool(string input, string term, bool enoughIsContainsAttribute, bool caseSensitive)

Parameters

input string

The text to search in.

term string

The term to search for.

enoughIsContainsAttribute bool

Whether partial contains match is sufficient.

caseSensitive bool

Whether the comparison is case-sensitive.

Returns

bool

ContainsBracket(string, bool)

Checks if the input string contains the specified content.

public static bool ContainsBracket(string text, bool isRequiringBothSides = false)

Parameters

text string
isRequiringBothSides bool

Returns

bool

ContainsBracket(string, ref List<char>?, ref List<char>?, bool)

Checks if the input string contains the specified content.

public static bool ContainsBracket(string text, ref List<char>? left, ref List<char>? right, bool isRequiringBothSides = false)

Parameters

text string
left List<char>
right List<char>
isRequiringBothSides bool

Returns

bool

ContainsCl(string, StringOrStringList, SearchStrategy, bool, bool)

Checks if the input string contains the specified content.

public static bool ContainsCl(string input, StringOrStringList searchTerm, SearchStrategy searchStrategy = SearchStrategy.FixedSpace, bool caseSensitive = false, bool isEnoughPartialContainsOfSplitted = true)

Parameters

input string
searchTerm StringOrStringList
searchStrategy SearchStrategy
caseSensitive bool
isEnoughPartialContainsOfSplitted bool

Returns

bool

ContainsDiacritic(string)

Checks whether the text contains any diacritical characters.

public static bool ContainsDiacritic(string word)

Parameters

word string

The text to check for diacritics.

Returns

bool

ContainsFromEnd(string, char, out int)

Checks if the input string contains the specified content.

public static bool ContainsFromEnd(string input, char character, out int foundIndex)

Parameters

input string

The string to search.

character char

The character to find.

foundIndex int

The index of the found character, or -1 if not found.

Returns

bool

ContainsLine(string, bool, params string[])

Checks if the input string contains the specified content.

public static bool ContainsLine(string text, bool isCheckingCaseForSingleString, params string[] contains)

Parameters

text string
isCheckingCaseForSingleString bool
contains string[]

Returns

bool

ContainsLine2(string, bool, IList<string>)

Whether A1 contains any from a3. a2 only logical chcek

public static bool ContainsLine2(string text, bool isCheckingCaseForSingleString, IList<string> contains)

Parameters

text string

The text to search in.

isCheckingCaseForSingleString bool

Whether to check containment when only one string is provided.

contains IList<string>

The strings to search for.

Returns

bool

ContainsLower(string)

Checks if the input string contains the specified content.

public static bool ContainsLower(string text)

Parameters

text string

Returns

bool

ContainsNewLine(string)

Checks if the input string contains the specified content.

public static bool ContainsNewLine(string text)

Parameters

text string

Returns

bool

ContainsOnly(string, List<char>)

Checks if the input string contains the specified content.

public static bool ContainsOnly(string input, List<char> numericChars)

Parameters

input string
numericChars List<char>

Returns

bool

ContainsOnlyCase(string, bool, bool)

Checks if the input string contains the specified content.

public static bool ContainsOnlyCase(string text, bool isUpper, bool isIgnoringOtherThanLetters = false)

Parameters

text string

The text to check.

isUpper bool

Whether to check for uppercase (true) or lowercase (false).

isIgnoringOtherThanLetters bool

Whether to skip non-letter characters instead of returning false.

Returns

bool

ContainsOtherCharThanLetterAndDigit(string)

Checks if the input string contains the specified content.

public static bool ContainsOtherCharThanLetterAndDigit(string text)

Parameters

text string

Returns

bool

ContainsUpper(string)

Checks if the input string contains the specified content.

public static bool ContainsUpper(string text)

Parameters

text string

Returns

bool

ContainsVariable(char, char, string)

Checks whether the text contains a format variable enclosed by the specified bracket characters.

public static bool ContainsVariable(char openingChar, char closingChar, string text)

Parameters

openingChar char

The opening bracket character.

closingChar char

The closing bracket character.

text string

The text to check for variables.

Returns

bool

ContainsVariable(string)

Checks if the input string contains the specified content.

public static bool ContainsVariable(string text)

Parameters

text string

The text to check for variables.

Returns

bool

ConvertPluralToSingleEn(string)

Converts an English plural word to its singular form by removing the trailing 's' or 'ies' suffix.

public static string ConvertPluralToSingleEn(string pluralWord)

Parameters

pluralWord string

Returns

string

ConvertTypedWhitespaceToString(string)

Convert \r\n to NewLine etc.

public static string ConvertTypedWhitespaceToString(string delimiter)

Parameters

delimiter string

The escaped whitespace string to convert (e.g. "\r\n", "\t").

Returns

string

ConvertWhitespaceToVisible(string)

Replaces whitespace characters (tab, newline, carriage return, space) with their visible Unicode equivalents.

public static string ConvertWhitespaceToVisible(string text)

Parameters

text string

The text in which to replace whitespace with visible characters.

Returns

string

CountLines(string)

Counts the specified elements in the string.

public static int CountLines(string text)

Parameters

text string

Returns

int

CountOf(string, char)

Counts the specified elements in the string.

public static int CountOf(string input, char character)

Parameters

input string
character char

Returns

int

CountOfItems(List<KeyValuePair<string, int>>)

Counts the specified elements in the string.

public static string CountOfItems(List<KeyValuePair<string, int>> counted)

Parameters

counted List<KeyValuePair<string, int>>

Returns

string

DeleteCharsOutOfAscii(string)

Deletes characters outside the valid range.

public static string DeleteCharsOutOfAscii(string text)

Parameters

text string

Returns

string

DetectNewline(string)

Detects the newline format used in the text (CRLF or LF).

public static string DetectNewline(string text)

Parameters

text string

The text to analyze for newline format.

Returns

string

EndsWith(string, string)

Checks if the string ends with the specified suffix.

public static bool EndsWith(string input, string endsWith)

Parameters

input string
endsWith string

Returns

bool

EndsWithArray(string, params string[])

Returns whether the source string ends with any of the provided suffixes.

public static bool EndsWithArray(string source, params string[] suffixes)

Parameters

source string

The string to check.

suffixes string[]

The suffixes to check against.

Returns

bool

EndsWithIndex(string, params string[])

Checks if the string ends with the specified suffix.

public static int EndsWithIndex(string source, params string[] endingsToCheck)

Parameters

source string
endingsToCheck string[]

Returns

int

EndsWithNumber(string)

Checks if the string ends with the specified suffix.

public static bool EndsWithNumber(string input)

Parameters

input string

Returns

bool

EqualsOneOfThis(string, params string[])

Checks equality of the string against specified values.

public static bool EqualsOneOfThis(string text, params string[] values)

Parameters

text string

The text to compare.

values string[]

The values to compare against.

Returns

bool

FindClosingBracketIndex(StringBuilder, bool, int)

Finds the index of the closing bracket that matches the opening bracket at the specified start index.

public static int FindClosingBracketIndex(StringBuilder stringBuilder, bool isRemovingBetween, int startIndex)

Parameters

stringBuilder StringBuilder

The StringBuilder to search within.

isRemovingBetween bool

Whether to replace characters between the brackets with spaces.

startIndex int

The index of the opening bracket character.

Returns

int

FindClosingBracketIndexChar(StringBuilder, bool, string)

Finds the index of the closing bracket matching the first occurrence of the specified opening bracket string.

public static int FindClosingBracketIndexChar(StringBuilder stringBuilder, bool isRemovingBetween, string openedBracket = "{")

Parameters

stringBuilder StringBuilder

The StringBuilder to search within.

isRemovingBetween bool

Whether to replace characters between the brackets with spaces.

openedBracket string

The opening bracket string to find.

Returns

int

FirstCharLower(string)

Processes or retrieves content from the beginning of the string.

public static string FirstCharLower(string input)

Parameters

input string

Returns

string

FirstCharOfEveryWordPart(string, string)

Dont automatically change case

public static string FirstCharOfEveryWordPart(string text, string delimiter)

Parameters

text string
delimiter string

Returns

string

FirstCharOfEveryWordUpperDash(string)

Return joined with space.

public static string FirstCharOfEveryWordUpperDash(string input)

Parameters

input string

Returns

string

FirstCharUpper(string)

Returns a new string with the first character converted to uppercase.

public static string FirstCharUpper(string text)

Parameters

text string

The text whose first character will be uppercased.

Returns

string

FirstCharUpper(string, bool)

Usage: Exceptions.FileWasntFoundInDirectory

public static string FirstCharUpper(string text, bool isOnlyFirstLetter = false)

Parameters

text string

The string whose first character to uppercase.

isOnlyFirstLetter bool

Whether to lowercase the rest of the string.

Returns

string

FirstCharUpper(ref string)

Converts the first character of the text to uppercase, modifying the ref parameter in place.

public static void FirstCharUpper(ref string text)

Parameters

text string

The text whose first character will be uppercased.

FirstLine(string)

Usage: Exc.MethodOfOccuredFromStackTrace

public static string FirstLine(string text)

Parameters

text string

The text to extract the first line from.

Returns

string

FirstWhichIsNotEmpty(params string[])

Returns the first non-empty string from the provided values.

public static string FirstWhichIsNotEmpty(params string[] values)

Parameters

values string[]

The strings to check.

Returns

string

FirstWordWhichIsNumber(string, int, bool)

keep shouldJoinAdjacentNumbers = false

public static int FirstWordWhichIsNumber(string input, int probablyIndex, bool shouldJoinAdjacentNumbers = false)

Parameters

input string

The string to search for a number word in.

probablyIndex int

The index to check first for a number word.

shouldJoinAdjacentNumbers bool

Whether to join adjacent number words together.

Returns

int

FirstWordWhichIsNumberAllIndexes(List<string>, bool)

Processes or retrieves content from the beginning of the string.

public static int FirstWordWhichIsNumberAllIndexes(List<string> words, bool shouldJoinAdjacentNumbers = true)

Parameters

words List<string>
shouldJoinAdjacentNumbers bool

Returns

int

FromSpace160To32(string)

Replaces non-breaking spaces (char 160) and other Unicode space separators with regular spaces (char 32).

public static string FromSpace160To32(string text)

Parameters

text string

The text in which to normalize space characters.

Returns

string

GetCharsInRange(string, int, int)

Returns whether any characters in the text have a char code in the range defined by min and max.

public static bool GetCharsInRange(string text, int min, int max)

Parameters

text string
min int
max int

Returns

bool

GetFirstChar(string)

Returns the first character of the text.

public static char GetFirstChar(string text)

Parameters

text string

The text from which to get the first character.

Returns

char

GetFirstPartByLocation(string, char)

Returns the first part of the string before the specified delimiter character. The delimiter can only be a single character. If the delimiter is not found, returns the entire string.

public static string GetFirstPartByLocation(string input, char delimiter)

Parameters

input string

The string to split.

delimiter char

The delimiter character.

Returns

string

GetFirstPartByLocation(string, int)

Retrieves the first part of the string up to the delimiter index.

public static string GetFirstPartByLocation(string input, int delimiterIndex)

Parameters

input string
delimiterIndex int

Returns

string

GetFirstWord(string, bool)

Returns the first word from the text, or empty string if no space is found.

public static string GetFirstWord(string text, bool returnEmptyWhenDontHaveLenght = true)

Parameters

text string

The string to extract the first word from.

returnEmptyWhenDontHaveLenght bool

Whether to return empty string when no space is found.

Returns

string

GetIndexesOfLinesStartingWith(List<string>, Func<string, bool>)

Returns the indexes of lines in the list that match the given predicate.

public static List<int> GetIndexesOfLinesStartingWith(List<string> list, Func<string, bool> predicate)

Parameters

list List<string>

The list of lines to search.

predicate Func<string, bool>

A function that determines which lines match.

Returns

List<int>

GetLastPartByString(string, string)

Returns the substring after the last occurrence of the search term, or the original string if not found.

public static string GetLastPartByString(string input, string returnFromString)

Parameters

input string

The string to search within.

returnFromString string

The substring to search for the last occurrence of.

Returns

string

GetLastWord(string, bool)

Retrieves the specified portion or data from the string.

public static string GetLastWord(string text, bool returnEmptyWhenDontHaveLenght = true)

Parameters

text string
returnEmptyWhenDontHaveLenght bool

Returns

string

GetLineFromCharIndex(string, List<string>, int)

Nothing can be null

public static string GetLineFromCharIndex(string text, List<string> lines, int characterIndex)

Parameters

text string
lines List<string>
characterIndex int

Returns

string

GetLineIndexFromCharIndex(string, int)

Return index, therefore x-1

public static int GetLineIndexFromCharIndex(string text, int characterPosition)

Parameters

text string
characterPosition int

Returns

int

GetOddIndexesOfWord(string)

Retrieves the specified portion or data from the string.

public static string GetOddIndexesOfWord(string input)

Parameters

input string

Returns

string

GetPairsStartAndEnd(List<int>, List<int>, ref List<int>?, ref List<int>?)

Performs an operation.

public static List<Tuple<int, int>> GetPairsStartAndEnd(List<int> leftBracketOccurrences, List<int> rightBracketOccurrences, ref List<int>? unmatchedLeftBrackets, ref List<int>? unmatchedRightBrackets)

Parameters

leftBracketOccurrences List<int>
rightBracketOccurrences List<int>
unmatchedLeftBrackets List<int>
unmatchedRightBrackets List<int>

Returns

List<Tuple<int, int>>

GetPartsByLocation(out string, out string, string, char)

Splits the text into two parts at the first occurrence of the delimiter character.

public static void GetPartsByLocation(out string before, out string after, string text, char delimiter)

Parameters

before string

The part of the text before the delimiter.

after string

The part of the text after the delimiter.

text string

The text to split.

delimiter char

The character at which to split.

GetPartsByLocation(out string, out string, string, int)

Splits the text into two parts at the specified position. Never put null into before/after.

public static void GetPartsByLocation(out string before, out string after, string text, int position)

Parameters

before string

The part of the text before the position.

after string

The part of the text after the position.

text string

The text to split.

position int

The index at which to split.

GetPartsByLocationNoOut(string, char)

Splits the text into two parts at the first occurrence of the delimiter, returning a tuple instead of out parameters.

public static (string, string) GetPartsByLocationNoOut(string text, char delimiter)

Parameters

text string

The text to split.

delimiter char

The character at which to split.

Returns

(string, string)

GetPartsByLocationNoOutInt(string, int)

Splits the text into two parts at the specified position, returning a tuple instead of out parameters.

public static (string, string) GetPartsByLocationNoOutInt(string text, int position)

Parameters

text string

The text to split.

position int

The index at which to split.

Returns

(string, string)

GetTextBetween(string, char, char, bool, object?, bool)

Extracts text between two delimiter characters. The notAllowedInRanges parameter can be a delegate or FromToList to exclude certain index ranges.

public static string GetTextBetween(string parameter, char after, char before, bool throwExceptionIfNotContains = true, object? notAllowedInRanges = null, bool endLastIndexOf = false)

Parameters

parameter string

The string to extract text from.

after char

The character after which to start extraction.

before char

The character before which to stop extraction.

throwExceptionIfNotContains bool

Whether to throw if delimiters are not found.

notAllowedInRanges object

Ranges that are not allowed for the end index.

endLastIndexOf bool

Whether to use LastIndexOf for the end character.

Returns

string

GetTextBetween(string, string, string, out int, int, bool)

Returns the text between the after and before markers, starting search from the specified index.

public static string GetTextBetween(string text, string after, string before, out int foundIndex, int startSearchingAt, bool throwExceptionIfNotContains = true)

Parameters

text string
after string
before string
foundIndex int
startSearchingAt int
throwExceptionIfNotContains bool

Returns

string

GetTextBetweenSimple(string, string, string, bool)

Returns the text between the after and before markers without exposing the found index.

public static string GetTextBetweenSimple(string text, string after, string before, bool throwExceptionIfNotContains = true)

Parameters

text string
after string
before string
throwExceptionIfNotContains bool

Returns

string

GetTextBetweenTwoChars(string, char, char, bool, object?, bool)

Returns the text between the first occurrence of beginChar and the matching endChar. notAllowedInRanges can be Func<int, bool> or FromToList to skip certain end positions.

public static string GetTextBetweenTwoChars(string text, char beginChar, char endChar, bool isThrowingIfNotContains = true, object? notAllowedInRanges = null, bool isUsingLastIndexOf = false)

Parameters

text string

The text to search within.

beginChar char

The opening character.

endChar char

The closing character.

isThrowingIfNotContains bool

Whether to throw an exception if the characters are not found.

notAllowedInRanges object

Optional range checker to skip certain end positions.

isUsingLastIndexOf bool

Whether to use LastIndexOf for the end character.

Returns

string

GetTextBetweenTwoCharsInts(string, int, int)

Returns the substring between the begin and end index positions (exclusive of both boundary characters).

public static string GetTextBetweenTwoCharsInts(string text, int beginIndex, int endIndex)

Parameters

text string

The text to extract from.

beginIndex int

The index of the opening character.

endIndex int

The index of the closing character.

Returns

string

GetTextInLastSquareBracketsAndOther(string, out string, out string)

Retrieves the specified portion or data from the string.

public static bool GetTextInLastSquareBracketsAndOther(string text, out string mainText, out string bracketedText)

Parameters

text string
mainText string
bracketedText string

Returns

bool

GetTextsBetween(string, string, string, bool)

Get Texts Between operation on the input.

public static List<string> GetTextsBetween(string text, string afterDelimiter, string beforeDelimiter, bool isRequiringNonLetterBeforeMatch = false)

Parameters

text string
afterDelimiter string
beforeDelimiter string
isRequiringNonLetterBeforeMatch bool

Returns

List<string>

GetTextsBetween(string, string, string, bool, out bool)

Get Texts Between operation on the input.

public static List<string> GetTextsBetween(string text, string afterDelimiter, string beforeDelimiter, bool isRequiringNonLetterBeforeMatch, out bool firstCharBeforeIsLetter)

Parameters

text string
afterDelimiter string
beforeDelimiter string
isRequiringNonLetterBeforeMatch bool
firstCharBeforeIsLetter bool

Returns

List<string>

GetToFirst(string, string)

Return A1 if wont find A2

public static string GetToFirst(string input, string searchFor)

Parameters

input string

The string to search within.

searchFor string

The substring to find the first occurrence of.

Returns

string

GetToFirstChar(string, int)

Retrieves the specified portion or data from the string.

public static string GetToFirstChar(string input, int indexOfChar)

Parameters

input string
indexOfChar int

Returns

string

GetVariablesInString(char, char, string)

Returns the list of format variable indices found in the text, using the specified bracket characters.

public static List<int> GetVariablesInString(char openingChar, char closingChar, string text)

Parameters

openingChar char

The opening bracket character.

closingChar char

The closing bracket character.

text string

The text to search for variable references.

Returns

List<int>

GetVariablesInString(string)

Get Variables In String operation on the input.

public static List<int> GetVariablesInString(string text)

Parameters

text string

The text to search for variable references.

Returns

List<int>

GetWhitespaceFromBeginning(StringBuilder, string)

Retrieves the specified portion or data from the string.

public static string GetWhitespaceFromBeginning(StringBuilder stringBuilder, string line)

Parameters

stringBuilder StringBuilder
line string

Returns

string

GetWithoutFirstWord(string)

Retrieves the specified portion or data from the string.

public static string GetWithoutFirstWord(string text)

Parameters

text string

Returns

string

GetWithoutLastWord(string)

Retrieves the specified portion or data from the string.

public static string GetWithoutLastWord(string text)

Parameters

text string

Returns

string

GetWordOnIndex(string, int)

Gets the word at the specified character index in the line.

[Obsolete("This method relied on SHData.ReturnCharsForSplitBySpaceAndPunctuationCharsAndWhiteSpaces which was overly complex. Do not restore, rewrite if needed.")]
public static string? GetWordOnIndex(string line, int index)

Parameters

line string
index int

Returns

string

HasCharRightFormat(char, CharFormatDataString)

Checks whether the string has the specified characteristic.

public static bool HasCharRightFormat(char character, CharFormatDataString charFormatData)

Parameters

character char
charFormatData CharFormatDataString

Returns

bool

HasIndex(int, string, bool)

Checks whether the string has the specified characteristic.

public static bool HasIndex(int parameter, string text, bool isThrowingExceptionOnInvalidIndex = true)

Parameters

parameter int
text string
isThrowingExceptionOnInvalidIndex bool

Returns

bool

HasLetter(string)

Checks whether the string has the specified characteristic.

public static bool HasLetter(string text)

Parameters

text string

Returns

bool

InBrackets(string)

In Brackets operation on the string.

public static string InBrackets(string input)

Parameters

input string

Returns

string

IncludeBrackets(string, bool)

Include Brackets operation on the input.

public static List<char> IncludeBrackets(string text, bool starting)

Parameters

text string
starting bool

Returns

List<char>

IncrementLastNumber(ref string)

When there is no number, append 1 Otherwise incr.

public static void IncrementLastNumber(ref string input)

Parameters

input string

IndentAsPreviousLine(List<string>)

Adjusts indentation of lines based on the previous line.

public static void IndentAsPreviousLine(List<string> lines)

Parameters

lines List<string>

IndexesOfBrackets(string)

Builds a map of bracket positions and line-based bracket positions in the text.

public static Tuple<SquareMap, SquareMapLines> IndexesOfBrackets(string text)

Parameters

text string

The text to scan for brackets.

Returns

Tuple<SquareMap, SquareMapLines>

IndexesOfChars(string, char)

Indexes Of Chars operation on the input.

public static List<int> IndexesOfChars(string input, char searchChar)

Parameters

input string
searchChar char

Returns

List<int>

IndexesOfCharsList(string, List<char>)

IndexesOfChars - char ReturnOccurencesOfString - string

public static List<int> IndexesOfCharsList(string text, List<char> characters)

Parameters

text string
characters List<char>

Returns

List<int>

Init()

Initializes bracket mappings and related data structures.

protected static void Init()

InsertBeforeEndingBracket(string, string)

Inserts the specified text before the last closing parenthesis in the source text.

public static string InsertBeforeEndingBracket(string text, string textToInsert)

Parameters

text string

The text containing a closing parenthesis to insert before.

textToInsert string

The text to insert before the closing parenthesis.

Returns

string

InsertEndingBracket(string, char)

Inserts content into the string at the specified position.

public static string InsertEndingBracket(string input, char startingBracket)

Parameters

input string
startingBracket char

Returns

string

InsertEndingBracket(string, List<char>, List<char>)

Inserts content into the string at the specified position.

public static string InsertEndingBracket(string input, List<char> openingBrackets, List<char> closingBrackets)

Parameters

input string
openingBrackets List<char>
closingBrackets List<char>

Returns

string

InsertEndingBracketWorker(string, int, int, List<char>, char)

Inserts content into the string at the specified position.

public static string InsertEndingBracketWorker(string input, int openingCount, int closingCount, List<char> openingBrackets, char startingBracket)

Parameters

input string
openingCount int
closingCount int
openingBrackets List<char>
startingBracket char

Returns

string

IsAllLower(string)

Determines whether the string matches the specified condition.

public static bool IsAllLower(string text)

Parameters

text string

Returns

bool

IsAllUpper(string)

Determines whether the string matches the specified condition.

public static bool IsAllUpper(string text)

Parameters

text string

Returns

bool

IsChinese(string)

Detects whether the text contains Chinese, Japanese (hiragana, katakana, kanji) or similar characters.

public static bool IsChinese(string text)

Parameters

text string

Returns

bool

IsContained(string, string)

Version wo ref - dont auto remove first!

public static bool IsContained(string text, string searchTerm)

Parameters

text string

The string to check against.

searchTerm string

The search term, optionally prefixed with '!' for negation.

Returns

bool

True if the containment condition is satisfied.

IsContained(string, ref string)

Auto remove potentially first !

public static bool IsContained(string input, ref string contains)

Parameters

input string

The text to search in.

contains string

The term to check for containment.

Returns

bool

IsNegation(string)

Determines whether the string matches the specified condition.

public static bool IsNegation(string searchTerm)

Parameters

searchTerm string

Returns

bool

IsNegationTuple(string)

Is Negation Tuple on the input.

public static (bool, string) IsNegationTuple(string searchTerm)

Parameters

searchTerm string

Returns

(bool, string)

IsNullOrWhiteSpace(string)

Determines whether the string is null, empty, or consists only of whitespace characters.

public static bool IsNullOrWhiteSpace(string text)

Parameters

text string

Returns

bool

IsNullOrWhiteSpaceRange(params string[])

Returns true if any of the provided strings is null or whitespace.

public static bool IsNullOrWhiteSpaceRange(params string[] array)

Parameters

array string[]

The strings to check.

Returns

bool

IsNumber(string, params char[])

Checks whether the text consists only of numeric characters and the additionally allowed characters.

public static bool IsNumber(string text, params char[] nextAllowedChars)

Parameters

text string

The text to check.

nextAllowedChars char[]

Additional characters that are allowed besides digits.

Returns

bool

IsNumbered(string)

Determines whether the string matches the specified condition.

public static bool IsNumbered(string input)

Parameters

input string

Returns

bool

IsOnIndex(string, int, Func<char, bool>)

Determines whether the string matches the specified condition.

public static bool IsOnIndex(string input, int index, Func<char, bool> predicate)

Parameters

input string
index int
predicate Func<char, bool>

Returns

bool

IsSingleLine(string)

Determines whether the string matches the specified condition.

public static bool IsSingleLine(string text)

Parameters

text string

Returns

bool

IsValidISO(string)

Determines whether the string matches the specified condition.

public static bool IsValidISO(string input)

Parameters

input string

Returns

bool

LastCharEquals(string, char)

Processes or retrieves content from the end of the string.

public static bool LastCharEquals(string input, char delimiter)

Parameters

input string
delimiter char

Returns

bool

LastChars(string, int)

Processes or retrieves content from the end of the string.

public static string LastChars(string text, int characterCount)

Parameters

text string
characterCount int

Returns

string

Leading(string, Func<char, bool>)

Gets leading characters matching the predicate.

public static string Leading(string input, Func<char, bool> predicate)

Parameters

input string
predicate Func<char, bool>

Returns

string

MakeUpToXChars(int, int)

Pads the number with leading zeros to reach the specified target length.

public static string MakeUpToXChars(int number, int targetLength)

Parameters

number int

The number to pad.

targetLength int

The desired total length of the resulting string.

Returns

string

MatchWildcard(string, string)

Checks whether the text matches the wildcard pattern using ? and * wildcards.

public static bool MatchWildcard(string text, string wildcardPattern)

Parameters

text string

The text to match against the pattern.

wildcardPattern string

The wildcard pattern with ? (single char) and * (multiple chars).

Returns

bool

MultiWhitespaceLineToSingle(List<string>)

Reduces multiple whitespace lines to a single one.

public static string MultiWhitespaceLineToSingle(List<string> lines)

Parameters

lines List<string>

Returns

string

NormalizeString(string)

Normalizes the string by standardizing its format.

public static string NormalizeString(string input)

Parameters

input string

Returns

string

NotAllowedInRanges(object, int)

Checks whether the given index is not allowed according to the range checker (can be Func<int, bool> or FromToList).

public static bool NotAllowedInRanges(object rangeChecker, int indexToTest)

Parameters

rangeChecker object

The range checker object, either a Func<int, bool> or a FromToList.

indexToTest int

The index to validate against the range.

Returns

bool

NullToStringOrDefault(object)

Converts the object to its string representation prefixed with a space, or returns " (null)" if null. Used for BadFormatOfElementInList formatting.

public static string NullToStringOrDefault(object nullableObject)

Parameters

nullableObject object

The object to convert, or null.

Returns

string

NullToStringOrEmpty(object)

Converts a possibly null object to its string representation, returning empty string for null.

public static string NullToStringOrEmpty(object value)

Parameters

value object

Returns

string

NullToStringOrNull(object?)

Converts the object to its string representation, returning null if the object is null. Unlike NullToStringOrEmpty, this returns null instead of empty string.

public static string? NullToStringOrNull(object? value)

Parameters

value object

The object to convert to string, or null.

Returns

string

OccurencesOfStringIn(string, string)

Counts occurrences of the specified search term in the source text.

public static int OccurencesOfStringIn(string text, string searchTerm)

Parameters

text string

The text to search within.

searchTerm string

The term to count occurrences of.

Returns

int

PadRight(string, string, int)

Pads the string to the specified length.

public static string PadRight(string baseString, string paddingText, int characterCount)

Parameters

baseString string
paddingText string
characterCount int

Returns

string

PairsBracketsToCompleteBlock(string)

Processes paired bracket elements in the string.

public static string PairsBracketsToCompleteBlock(string input)

Parameters

input string

Returns

string

PostfixIfNotEmpty(string, string)

Add postfix if text not ends with

public static string PostfixIfNotEmpty(string input, string postfix)

Parameters

input string

The text to add the postfix to.

postfix string

The postfix to append.

Returns

string

PrefixIfNotStartedWith(string, string, bool)

Adds a prefix to the string if not already present.

public static string PrefixIfNotStartedWith(string text, string prefix, bool skipWhitespaces = false)

Parameters

text string
prefix string
skipWhitespaces bool

Returns

string

RemoveAndInsertReplace(string, int, string, string)

Removes specified content from the string.

public static string RemoveAndInsertReplace(string input, int startIndex, string oldValue, string newValue)

Parameters

input string
startIndex int
oldValue string
newValue string

Returns

string

RemoveBetweenAndEdgeChars(string, string, string)

Removes text between begin and end markers including the markers themselves. A2,3 can be string or char.

public static string RemoveBetweenAndEdgeChars(string text, string begin, string end)

Parameters

text string
begin string
end string

Returns

string

RemoveBracketsAndHisContent(string, bool, bool, bool, bool)

Removes brackets and their content from the input string, optionally removes text after " - from" clause.

public static string RemoveBracketsAndHisContent(string input, bool squareBrackets, bool parentheses, bool braces, bool afterSdsFrom)

Parameters

input string
squareBrackets bool
parentheses bool
braces bool
afterSdsFrom bool

Returns

string

RemoveBracketsFromStart(string)

Removes leading bracket pairs (parentheses or square brackets) from the beginning of the string.

public static string RemoveBracketsFromStart(string text)

Parameters

text string

The string from which leading brackets will be removed.

Returns

string

RemoveBracketsWithTextCaseInsensitive(string, string, params string[])

Removes specified content from the string.

public static string RemoveBracketsWithTextCaseInsensitive(string input, string replacement, params string[] patterns)

Parameters

input string
replacement string
patterns string[]

Returns

string

RemoveBracketsWithoutText(string)

Removes specified content from the string.

public static string RemoveBracketsWithoutText(string input)

Parameters

input string

Returns

string

RemoveDiacritics(string)

Not working for czech, same as https://stackoverflow.com/a/249126

public static string RemoveDiacritics(string text)

Parameters

text string

The string from which to remove diacritics.

Returns

string

RemoveDuplicates(string, string)

Really return list, for string join value

public static List<string> RemoveDuplicates(string input, string delimiter)

Parameters

input string

The text to process.

delimiter string

The delimiter to split by before removing duplicates.

Returns

List<string>

RemoveDuplicatesNone(string, string)

Remove Duplicates None operation on the input.

public static List<string> RemoveDuplicatesNone(string input, string delimiter)

Parameters

input string
delimiter string

Returns

List<string>

RemoveEndingPairCharsWhenDontHaveStarting(string, string, string)

Removes specified content from the string.

public static string RemoveEndingPairCharsWhenDontHaveStarting(string input, string leftBracket, string rightBracket)

Parameters

input string
leftBracket string
rightBracket string

Returns

string

RemoveLastChar(string)

Removes specified content from the string.

public static string RemoveLastChar(string input)

Parameters

input string

Returns

string

RemoveLastCharIfIs(string, char)

Removes the last character of the string if it matches the specified character.

public static string RemoveLastCharIfIs(string text, char character)

Parameters

text string

The string to check and modify.

character char

The character to match against the last character.

Returns

string

RemoveLastCharSb(StringBuilder)

Removes specified content from the string.

public static void RemoveLastCharSb(StringBuilder stringBuilder)

Parameters

stringBuilder StringBuilder

RemoveLastLetters(string, int)

Removes specified content from the string.

public static string RemoveLastLetters(string input, int characterCount)

Parameters

input string
characterCount int

Returns

string

RemoveLastWord(string)

Removes the last word from the text by trimming and cutting at the last space.

public static string RemoveLastWord(string text)

Parameters

text string

The text from which to remove the last word.

Returns

string

RemoveLinesWhichContains(string, string)

Removes all lines from the text that contain the specified substring.

public static string RemoveLinesWhichContains(string text, string textToRemove)

Parameters

text string

The multiline text to filter.

textToRemove string

The substring whose containing lines will be removed.

Returns

string

RemovePrefix(ref string, string)

Removes the specified prefix from the string if it starts with it.

public static bool RemovePrefix(ref string text, string prefix)

Parameters

text string
prefix string

Returns

bool

RemoveUselessWhitespaces(string)

Removes specified content from the string.

public static string RemoveUselessWhitespaces(string text)

Parameters

text string

Returns

string

RepairQuotes(string)

Repairs malformed content in the string.

public static string RepairQuotes(string text)

Parameters

text string

Returns

string

ReplaceBrackets(string, Brackets, Brackets)

Replaces all occurrences of one bracket type with another in the text.

public static string ReplaceBrackets(string text, Brackets what, Brackets replacement)

Parameters

text string

The text in which to replace brackets.

what Brackets

The bracket type to replace.

replacement Brackets

The bracket type to replace with.

Returns

string

ReplaceOnce(string, string, string)

Replaces content in the string.

public static string ReplaceOnce(string input, string oldValue, string replacement)

Parameters

input string
oldValue string
replacement string

Returns

string

ReplaceOnceIfStartedWith(string, string, string)

Replaces content in the string.

public static string ReplaceOnceIfStartedWith(string input, string searchPrefix, string replacement)

Parameters

input string
searchPrefix string
replacement string

Returns

string

ReplaceOnceIfStartedWith(string, string, string, out bool)

Replaces content in the string.

public static string ReplaceOnceIfStartedWith(string input, string searchPrefix, string replacement, out bool replaced)

Parameters

input string
searchPrefix string
replacement string
replaced bool

Returns

string

ReturnOccurencesOfString(string, string)

IndexesOfChars - char ReturnOccurencesOfString - string

public static List<int> ReturnOccurencesOfString(string searchText, string searchTerm)

Parameters

searchText string

The text to search in.

searchTerm string

The term to find occurrences of.

Returns

List<int>

ReturnOccurencesOfStringFromTo(string, string)

Returns a list of FromToString where each element contains the start index and end index of each occurrence of the search term.

public static List<FromToString> ReturnOccurencesOfStringFromTo(string searchText, string searchTerm)

Parameters

searchText string

The string to search within.

searchTerm string

The substring to find all occurrences of.

Returns

List<FromToString>

ReturnOccurencesOfStringFromToWord(string, params string[])

Returns all occurrences of the searched words as FromToWord ranges within the text content.

public static List<FromToWordString> ReturnOccurencesOfStringFromToWord(string textContent, params string[] searchedWords)

Parameters

textContent string
searchedWords string[]

Returns

List<FromToWordString>

ShortForLettersCount(string, int)

Shortens the string to the specified length.

public static string ShortForLettersCount(string text, int maxLetterCount)

Parameters

text string

The text to shorten.

maxLetterCount int

The maximum number of characters.

Returns

string

ShortForLettersCountThreeDots(string, int)

Returns a shortened version of the text with three dots appended if truncated.

public static string ShortForLettersCountThreeDots(string text, int maxLetterCount)

Parameters

text string
maxLetterCount int

Returns

string

ShortForLettersCountThreeDotsReverse(string, int)

Returns a shortened version of the text from the end with three dots prepended if truncated. Returns max A2 characters, not words, because someone might insert overly long words.

public static string ShortForLettersCountThreeDotsReverse(string text, int maxLetterCount)

Parameters

text string
maxLetterCount int

Returns

string

ShortToLengthByParagraph(string, int)

Is used in btnShortTextOfLyrics Short text but always keep whole paragraps Can be use also for non paragraph strings abcd->ab

public static string ShortToLengthByParagraph(string text, int maxLength)

Parameters

text string
maxLength int

Returns

string

StartWithWhitespace(string)

Checks if the text starts with a whitespace character.

public static bool StartWithWhitespace(string text)

Parameters

text string

The text to check.

Returns

bool

StatisticLetterChars(string, StatisticLetterCharsStrategy, params char[])

Counts occurrences of each character in the text, applying the specified strategy for certain characters.

public static Dictionary<char, int> StatisticLetterChars(string text, StatisticLetterCharsStrategy strategy, params char[] charsToStrategy)

Parameters

text string

The text to analyze character frequencies in.

strategy StatisticLetterCharsStrategy

The strategy for handling specified characters (ignore or add first).

charsToStrategy char[]

The characters to which the strategy applies.

Returns

Dictionary<char, int>

StripFunctationsAndSymbols(string)

Strips punctuation and symbols from the string.

public static string StripFunctationsAndSymbols(string text)

Parameters

text string

Returns

string

SwitchSwap(string, string)

Splits the text by the delimiter and swaps the two parts.

public static string SwitchSwap(string text, string delimiter)

Parameters

text string

The text to split and swap.

delimiter string

The delimiter to split on.

Returns

string

TabOrSpaceNextTo(string)

Tab Or Space Next To operation on the input.

public static List<int> TabOrSpaceNextTo(string input)

Parameters

input string

Returns

List<int>

TabToNewLine(string)

Processes tab-related content in the string.

public static string TabToNewLine(string text)

Parameters

text string

Returns

string

TelephonePrefixToBrackets(string)

Insert prefix starting with +

public static string TelephonePrefixToBrackets(string input)

Parameters

input string

The telephone number string to process.

Returns

string

TextAfter(string, string)

Get text after cz#cd => #cd

public static string TextAfter(string text, string after)

Parameters

text string
after string

Returns

string

TextWithoutDiacritic(string)

Another method is RemoveDiacritics G text bez dia A1.

public static string TextWithoutDiacritic(string input)

Parameters

input string

The string from which to remove diacritics.

Returns

string

ToCase(string, bool?)

Converts the string to the specified format.

public static string ToCase(string input, bool? isUpperCase)

Parameters

input string
isUpperCase bool?

Returns

string

ToNumber<T>(Func<string, T>, string)

Performs an operation.

public static T ToNumber<T>(Func<string, T> parse, string input)

Parameters

parse Func<string, T>
input string

Returns

T

Type Parameters

T

ToPascalCase(string)

Converts a space-separated text into PascalCase by capitalizing the first letter of each word and joining them.

public static string ToPascalCase(string text)

Parameters

text string

The text to convert to PascalCase.

Returns

string

ValuesBetweenQuotes(string, bool, bool)

Values Between Quotes operation on the input.

public static List<string> ValuesBetweenQuotes(string text, bool isInsertingBackToQuotes, bool isUsingApostrophes = false)

Parameters

text string

The text to extract quoted values from.

isInsertingBackToQuotes bool

Whether to keep the quotes around each result.

isUsingApostrophes bool

Whether to use apostrophes instead of double quotes.

Returns

List<string>

ValuesBetweenQuotesAndApos(string, bool, bool)

Values Between Quotes And Apos operation on the input.

public static List<string> ValuesBetweenQuotesAndApos(string text, bool isInsertingBackToQuotes, bool isFilteringUnmatched = false)

Parameters

text string

The text to extract quoted values from.

isInsertingBackToQuotes bool

Whether to keep the quotes around each result.

isFilteringUnmatched bool

Whether to filter out unmatched quote patterns.

Returns

List<string>

WhiteSpaceFromStart(string)

Extracts whitespace characters from the specified position.

public static string WhiteSpaceFromStart(string input)

Parameters

input string

Returns

string

WithoutSpecialChars(string, params char[])

Without Special Chars operation on the string.

public static string WithoutSpecialChars(string input, params char[] excludedCharacters)

Parameters

input string
excludedCharacters char[]

Returns

string

WordAfter(string, string)

Gets the word at the specified position in the string.

public static string WordAfter(string input, string word)

Parameters

input string
word string

Returns

string

WrapWith(string, string)

Wraps the string with the specified wrapper on both sides.

public static string WrapWith(string value, string wrapper)

Parameters

value string
wrapper string

Returns

string

WrapWithBs(string)

Wraps the string with the specified characters.

public static string WrapWithBs(string input)

Parameters

input string

Returns

string

WrapWithChar(string, char, bool, bool)

Wraps the string with the specified character on both sides.

public static string WrapWithChar(string value, char wrapperChar, bool shouldTrimWrapping = false, bool shouldIncludeWhitespaceOrEmpty = true)

Parameters

value string
wrapperChar char
shouldTrimWrapping bool
shouldIncludeWhitespaceOrEmpty bool

Returns

string

WrapWithIf(string, string, Func<string, string, bool>)

Wraps the text with the specified wrapper if the predicate returns true.

public static string WrapWithIf(string text, string wrapper, Func<string, string, bool> predicate)

Parameters

text string

The text to conditionally wrap.

wrapper string

The wrapper string to apply around the text.

predicate Func<string, string, bool>

A function that determines whether wrapping should occur.

Returns

string

WrapWithQm(string)

Wraps the string with the specified characters.

public static string WrapWithQm(string input)

Parameters

input string

Returns

string

WrapWithQm(string, bool)

Wraps the text with quotation marks.

public static string WrapWithQm(string text, bool isWrappingWhitespaceOrEmpty = true)

Parameters

text string

The text to wrap with quotation marks.

isWrappingWhitespaceOrEmpty bool

Whether to also wrap if the text is whitespace or empty.

Returns

string

WrapWithSpace(string)

Wraps the string with the specified characters.

public static string WrapWithSpace(string input)

Parameters

input string

Returns

string

XCharsBeforeAndAfterWholeWords(string, int, int)

Returns whole words around the middle index within the specified character count per side. It is recommended to convert whitespace characters in A1 to spaces before calling this method.

public static string XCharsBeforeAndAfterWholeWords(string textContent, int middleIndex, int charactersPerSide)

Parameters

textContent string
middleIndex int
charactersPerSide int

Returns

string