StringUtils extension
Extensions on String for real-world utility operations.
- on
Properties
- isAlpha → bool
-
Available on String, provided by the StringUtils extension
Returnstrueif this string contains only alphabetic characters.no setter - isAlphanumeric → bool
-
Available on String, provided by the StringUtils extension
Returnstrueif this string contains only alphanumeric characters.no setter - isDigits → bool
-
Available on String, provided by the StringUtils extension
Returnstrueif this string contains only digits (0–9).no setter - isEmail → bool
-
Available on String, provided by the StringUtils extension
Returnstrueif this is a valid email address.no setter - isHexColor → bool
-
Available on String, provided by the StringUtils extension
Returnstrueif this is a valid hexadecimal color (#RGBor#RRGGBB).no setter - isIPv4 → bool
-
Available on String, provided by the StringUtils extension
Returnstrueif this is a valid IPv4 address.no setter - isIPv6 → bool
-
Available on String, provided by the StringUtils extension
Returnstrueif this is a valid IPv6 address.no setter - isPalindrome → bool
-
Available on String, provided by the StringUtils extension
Returnstrueif this string is a palindrome (case-insensitive).no setter - isPhoneNumber → bool
-
Available on String, provided by the StringUtils extension
Returnstrueif this is a valid phone number (E.164 and common formats).no setter - isStrongPassword → bool
-
Available on String, provided by the StringUtils extension
Returnstrueif this is a strong password: at least 8 characters, one uppercase, one lowercase, one digit, one special character.no setter - isUrl → bool
-
Available on String, provided by the StringUtils extension
Returnstrueif this is a validhttp://orhttps://URL.no setter - vowelCount → int
-
Available on String, provided by the StringUtils extension
Returns the number of vowels in this string.no setter - wordCount → int
-
Available on String, provided by the StringUtils extension
Returns the number of words in this string.no setter
Methods
-
after(
String pattern) → String -
Available on String, provided by the StringUtils extension
Returns the substring after the first occurrence ofpattern. -
afterLast(
String pattern) → String -
Available on String, provided by the StringUtils extension
Returns the substring after the last occurrence ofpattern. -
append(
String other) → String -
Available on String, provided by the StringUtils extension
Appendsotherto this string. -
before(
String pattern) → String -
Available on String, provided by the StringUtils extension
Returns the substring before the first occurrence ofpattern. -
beforeLast(
String pattern) → String -
Available on String, provided by the StringUtils extension
Returns the substring before the last occurrence ofpattern. -
between(
String start, String end) → String -
Available on String, provided by the StringUtils extension
Returns the substring betweenstartandenddelimiters. -
capitalize(
) → String -
Available on String, provided by the StringUtils extension
Returns a new string with the first character in upper case. -
compactWhitespace(
) → String -
Available on String, provided by the StringUtils extension
Replaces all runs of whitespace with a single space and trims. -
constantize(
) → String -
Available on String, provided by the StringUtils extension
Converts this string to a constant name (UPPER_SNAKE_CASE). -
containsIgnoreCase(
String other) → bool -
Available on String, provided by the StringUtils extension
Returnstrueif this string containsother, ignoring case. -
countOccurrences(
String substring) → int -
Available on String, provided by the StringUtils extension
Counts the number of non-overlapping occurrences ofsubstring. -
dropLeft(
int n) → String -
Available on String, provided by the StringUtils extension
Drops the firstncharacters. Returns empty string ifn>= length. -
dropLeftWhile(
bool condition(String char)) → String -
Available on String, provided by the StringUtils extension
Drops characters from the left whileconditionis true. -
dropRight(
int n) → String -
Available on String, provided by the StringUtils extension
Drops the lastncharacters. Returns empty string ifn>= length. -
dropRightWhile(
bool condition(String char)) → String -
Available on String, provided by the StringUtils extension
Drops characters from the right whileconditionis true. -
equalsIgnoreCase(
String other) → bool -
Available on String, provided by the StringUtils extension
Returnstrueif this string equalsother, ignoring case. -
escape(
) → String -
Available on String, provided by the StringUtils extension
Escapes backslashes and double-quotes. -
extractEmails(
) → List< String> -
Available on String, provided by the StringUtils extension
Extracts all email addresses from this string. -
extractNumbers(
) → List< num> -
Available on String, provided by the StringUtils extension
Extracts all numbers (int and double) from this string. -
extractUrls(
) → List< String> -
Available on String, provided by the StringUtils extension
Extracts all http/https URLs from this string. -
foreignKey(
) → String -
Available on String, provided by the StringUtils extension
Converts this string to a foreign key name. -
format(
List< Object> args) → String -
Available on String, provided by the StringUtils extension
Formats this string using positional placeholders{0},{1}, etc. -
formatMap(
Map< String, Object> args) → String -
Available on String, provided by the StringUtils extension
Formats this string using named placeholders{key}. -
fromBase64(
) → String -
Available on String, provided by the StringUtils extension
Decodes a Base64-encoded string back to a plain string. -
humanize(
) → String -
Available on String, provided by the StringUtils extension
Converts a string into a human-readable form by inserting spaces before uppercase letters and lowercasing the result. -
initials(
{int max = 2}) → String -
Available on String, provided by the StringUtils extension
Returns initials from a name string (up tomaxcharacters). -
levenshteinDistance(
String other) → int -
Available on String, provided by the StringUtils extension
Returns the Levenshtein edit distance between this string andother. -
mask(
{int keepFirst = 0, int keepLast = 4, String maskChar = '*'}) → String -
Available on String, provided by the StringUtils extension
Masks this string, keepingkeepFirstcharacters at the start andkeepLastat the end, replacing the rest withmaskChar. -
pathize(
) → String -
Available on String, provided by the StringUtils extension
Converts this string to a path name. -
pluralize(
) → String -
Available on String, provided by the StringUtils extension
Naively pluralizes this string by appending 's'. -
prepend(
String other) → String -
Available on String, provided by the StringUtils extension
Prependsotherto this string. -
removePrefix(
String prefix) → String -
Available on String, provided by the StringUtils extension
Removesprefixfrom the start of this string if present. -
removeSuffix(
String suffix) → String -
Available on String, provided by the StringUtils extension
Removessuffixfrom the end of this string if present. -
removeWhitespace(
) → String -
Available on String, provided by the StringUtils extension
Removes all whitespace (including internal spaces) from this string. -
repeat(
int times, {String separator = ''}) → String -
Available on String, provided by the StringUtils extension
Repeats this stringtimestimes, joined byseparator. -
replaceAfterFirst(
String pattern, String replacement) → String -
Available on String, provided by the StringUtils extension
Replaces everything after the first occurrence ofpattern. -
replaceAfterLast(
String pattern, String replacement) → String -
Available on String, provided by the StringUtils extension
Replaces everything after the last occurrence ofpattern. -
replaceBeforeFirst(
String pattern, String replacement) → String -
Available on String, provided by the StringUtils extension
Replaces everything before the first occurrence ofpattern. -
replaceBeforeLast(
String pattern, String replacement) → String -
Available on String, provided by the StringUtils extension
Replaces everything before the last occurrence ofpattern. -
reverse(
) → String -
Available on String, provided by the StringUtils extension
Reverses this string. -
sequenceize(
) → String -
Available on String, provided by the StringUtils extension
Converts this string to a sequence name. -
similarityTo(
String other) → double -
Available on String, provided by the StringUtils extension
Returns a similarity score between 0.0 (completely different) and 1.0 (identical), based on Levenshtein distance. -
stripHtml(
) → String -
Available on String, provided by the StringUtils extension
Removes all HTML tags from this string. -
tableize(
) → String -
Available on String, provided by the StringUtils extension
Converts this string to a table name (pluralized snake_case). -
titleCase(
) → String -
Available on String, provided by the StringUtils extension
Capitalizes the first character of each word. -
toBase64(
) → String -
Available on String, provided by the StringUtils extension
Encodes this string to Base64. -
toBytes(
) → List< int> -
Available on String, provided by the StringUtils extension
Encodes this string to a UTF-8 byte list. -
toCamelCase(
) → String -
Available on String, provided by the StringUtils extension
Converts a string to camelCase. -
toColor(
) → Color? -
Available on String, provided by the StringUtils extension
Converts a hex color string to a Color. Returnsnullif the string is not a valid hex color. -
toDotCase(
) → String -
Available on String, provided by the StringUtils extension
Converts a string to dot.case. -
toHtmlText(
) → String -
Available on String, provided by the StringUtils extension
Escapes HTML special characters (<,>,&,",'). -
toKebabCase(
) → String -
Available on String, provided by the StringUtils extension
Converts a string to kebab-case. -
toPascalCase(
) → String -
Available on String, provided by the StringUtils extension
Converts a string to PascalCase. -
toSentenceCase(
) → String -
Available on String, provided by the StringUtils extension
Converts this string to sentence case (first letter uppercase, rest lower). -
toSlug(
) → String -
Available on String, provided by the StringUtils extension
Converts this string to a URL-friendly slug. -
toSnakeCase(
) → String -
Available on String, provided by the StringUtils extension
Converts a camelCase or PascalCase string to snake_case. -
toTrainCase(
) → String -
Available on String, provided by the StringUtils extension
Converts a string to Train-Case. -
truncate(
int maxLength, {String ellipsis = '…'}) → String -
Available on String, provided by the StringUtils extension
Truncates this string tomaxLengthcharacters, appendingellipsisif truncation occurs. -
truncateWords(
int maxWords, {String ellipsis = '…'}) → String -
Available on String, provided by the StringUtils extension
Truncates this string tomaxWordswords, appendingellipsisif truncation occurs. -
tryParseJson(
) → dynamic -
Available on String, provided by the StringUtils extension
Tries to parse this string as JSON. Returnsnullon failure. -
uncapitalize(
) → String -
Available on String, provided by the StringUtils extension
Returns a new string with the first character in lower case. -
underscore(
) → String -
Available on String, provided by the StringUtils extension
Converts a camelized string to all lower case separated by underscores. -
variablize(
) → String -
Available on String, provided by the StringUtils extension
Converts this string to a variable name (camelCase, no special chars). -
wordWrap(
int maxWidth) → String -
Available on String, provided by the StringUtils extension
Wraps this string atmaxWidthcharacters, breaking at word boundaries.