StringManipulationExtensions extension

Extensions on String for character manipulation, removal, and cleaning.

on

Methods

appendNotEmpty(String value) String

Available on String, provided by the StringManipulationExtensions extension

Returns this string with value appended, or an empty string if this string is empty.
getEverythingAfter(String find) String

Available on String, provided by the StringManipulationExtensions extension

Returns the substringSafe after the first occurrence of find. Returns the original string if find is not found.
getEverythingAfterLast(String find) String

Available on String, provided by the StringManipulationExtensions extension

Returns the substringSafe after the last occurrence of find. Returns the original string if find is not found.
getEverythingBefore(String find) String

Available on String, provided by the StringManipulationExtensions extension

Returns the substring before the first occurrence of find.
getRandomChar() String

Available on String, provided by the StringManipulationExtensions extension

Returns a random character from this string.
insert(String newChar, int position) String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with newChar inserted at the specified position.
isBracketWrapped() bool

Available on String, provided by the StringManipulationExtensions extension

Returns true if this string starts and ends with a matching bracket pair: parentheses, square brackets, curly braces, or angle brackets.
lettersOnly() String

Available on String, provided by the StringManipulationExtensions extension

Extracts only ASCII letter characters (A-Z, a-z) from this string.
lowerCaseLettersOnly() String

Available on String, provided by the StringManipulationExtensions extension

Extracts only ASCII lowercase letter characters (a-z) from this string.
makeNonBreaking() String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with hyphens and spaces replaced by non-breaking equivalents.
normalizeApostrophe() String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with apostrophe variants replaced by a standard single quote.
prefixNotEmpty(String? value) String

Available on String, provided by the StringManipulationExtensions extension

Returns this string with value prepended, or this string unchanged if empty.
removeAll(Pattern? pattern) String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with all occurrences of pattern removed.
removeEnd(String end) String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with end removed from the end, if it exists.
removeFirstChar() String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with the first character removed.
removeFirstLastChar() String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with both the first and last characters removed.
removeLastChar() String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with the last character removed.
removeLastOccurrence(String target) String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with the last occurrence of target removed.
removeLeadingAndTrailing(String? find, {bool trim = false}) String?

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with leading and trailing occurrences of find removed, or null if the result is empty.
removeMatchingWrappingBrackets() String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with the outer matching bracket pair removed.
removeNonAlphaNumeric({bool allowSpace = false}) String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with all non-alphanumeric characters removed.
removeNonNumbers() String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with all non-digit characters removed.
removeStart(String? start, {bool isCaseSensitive = true, bool trimFirst = false}) String?

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with start removed from the beginning, or null if the result is empty.
removeWrappingChar(String char, {bool trimFirst = true}) String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with char removed from the beginning and/or end.
repeat(int count) String

Available on String, provided by the StringManipulationExtensions extension

Returns this string repeated count times.
replaceLastNCharacters(int n, String replacementChar) String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with the last n characters replaced by replacementChar.
replaceLineBreaks(String? replacement, {bool deduplicate = true}) String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with all line breaks replaced by replacement.
replaceNonNumbers({String replacement = ''}) String

Available on String, provided by the StringManipulationExtensions extension

Replaces all characters that are not digits (0-9) with the replacement string.
toAlphaOnly({bool allowSpace = false}) String

Available on String, provided by the StringManipulationExtensions extension

Returns a new string with all non-letter characters removed.