Contact Us 1-800-596-4880

Strings (dw::core::Strings)

This module contains helper functions to work with Strings.

To use this module, you must import it to your DataWeave code, for example, by adding the line import * from dw::core::Strings to the header of your DataWeave script.

Functions

Name Description

appendIfMissing

Appends the suffix to the end of the text if the text does not already ends with the suffix.

camelize

Returns a string in camel case based on underscores in the string.

capitalize

Capitalizes the first letter of each word in a string.

charCode

Returns the Unicode for the first character in an input string.

charCodeAt

Returns the Unicode for a character at the specified index.

dasherize

Replaces spaces, underscores, and camel-casing in a string with dashes (hyphens).

fromCharCode

Returns a character that matches the specified Unicode.

isAlpha

Checks if the text contains only Unicode digits. A decimal point is not a Unicode digit and returns false.

isAlphanumeric

Checks if the text contains only Unicode letters or digits.

isLowerCase

Checks if the text contains only lowercase characters.

isNumeric

Checks if the text contains only Unicode digits.

isUpperCase

Checks if the text contains only uppercase characters.

isWhitespace

Checks if the text contains only whitespace.

leftPad

The specified text is left-padded to the size using the padText. By default padText is " ".

ordinalize

Returns a number as an ordinal, such as 1st or 2nd.

pluralize

Pluralizes a singular string.

prependIfMissing

Prepends the prefix to the beginning of the string if the text does not already start with that prefix.

repeat

Repeats a text the number of specified times.

rightPad

The specified text is right-padded to the size using the padText. By default padText is " ".

singularize

Converts a plural string to its singular form.

substringAfter

Gets the substring after the first occurrence of a separator. The separator is not returned.

substringAfterLast

Gets the substring after the last occurrence of a separator. The separator is not returned.

substringBefore

Gets the substring before the first occurrence of a separator. The separator is not returned.

substringBeforeLast

Gets the substring before the last occurrence of a separator. The separator is not returned.

underscore

Replaces hyphens, spaces, and camel-casing in a string with underscores.

unwrap

Unwraps a given text from a wrapper text.

withMaxSize

Checks that the string length is no larger than the specified maxLength. If the string’s length is larger than the maxLength, the function cuts characters from left to right, until the string length meets the length limit.

wrapIfMissing

Wraps text with wrapper if that wrapper is missing from the start or end of the given string.

wrapWith

Wraps the specified text with the given wrapper.