StringMoreExtensions extension

String More: strip leading/trailing substring, join lines, wrap at N, capitalize sentence, swap case, etc. Roadmap #251-265.

on

Methods

allIndicesOf(String substring) List<int>

Available on String, provided by the StringMoreExtensions extension

Returns all start indices where substring occurs (non-overlapping).
capitalizeSentences() String

Available on String, provided by the StringMoreExtensions extension

Capitalizes the first letter after sentence boundaries (start or after . ).
countOccurrences(String substring) int

Available on String, provided by the StringMoreExtensions extension

Counts non-overlapping occurrences of substring in this string.
firstNWords(int n) String

Available on String, provided by the StringMoreExtensions extension

Returns the first n words (split on whitespace). Returns empty string if n <= 0.
isPalindrome({bool ignoreCase = true, bool ignorePunctuation = false}) bool

Available on String, provided by the StringMoreExtensions extension

Returns true if this string reads the same forwards and backwards (optionally ignoring case/punctuation).
joinLines([String separator = '\n']) String

Available on String, provided by the StringMoreExtensions extension

Joins lines (split by newline) with separator. Default separator is newline (no-op).
lastNWords(int n) String

Available on String, provided by the StringMoreExtensions extension

Returns the last n words (split on whitespace), preserving their order.
padToWidth(int width, {bool padLeft = true, String padChar = ' '}) String

Available on String, provided by the StringMoreExtensions extension

Pads this string to width with padChar, on the left if padLeft else right.
removeRepeatedChars() String

Available on String, provided by the StringMoreExtensions extension

Collapses runs of the same character into one, keeping order.
reverseWords() String

Available on String, provided by the StringMoreExtensions extension

Reverses the order of words (split on whitespace).
stripHtmlComments() String

Available on String, provided by the StringMoreExtensions extension

Removes HTML comments () from this string.
stripSubstring(String substring) String

Available on String, provided by the StringMoreExtensions extension

Removes leading and trailing occurrences of substring until none remain.
swapCase() String

Available on String, provided by the StringMoreExtensions extension

Swaps upper-case and lower-case for each character.
wrapAtChars(int width) String

Available on String, provided by the StringMoreExtensions extension

Wraps this string at width character boundaries (grapheme-safe). Returns chunks joined by newline.