Split text

Value resolver – Abstract

Purpose: Splits the text present as input value at each occurrence for the optionally parameterizable Delimiter (string or a Regular expression) and returns the resulting substrings as a list (String[]).

images/download/attachments/62867074/image2023-1-4_12-0-5-version-1-modificationdate-1672830005321-api-v2.png

The Split text value resolver splits the text present as input value at each occurrence for the optionally parameterizable Delimiter (string or a Regular expression) and returns the resulting substrings as a list (String[]).

The Delimiter can be defined either by direct input as static text or by value resolvers.

Character (strings) evaluated as a Delimiter do not appear as part of the substring in the return value.

Overall, the following special cases should be noted:

  • If the input value is 'No value' ($null), the return value is also 'No value' ($null).

  • If there is an input value that is not a text (String), then the string image of the input value is processed.

  • The input value is divided after each character if one of the following conditions is met:

    • 'No value' ($null) was specified as the Delimiter.

    • An empty string ('') was specified as the Delimiter.

    • The value configuration for the Delimiter parameter returns 'No value' ($null) or an empty string ('') at runtime.

  • If all characters from the input value are interpreted as a Delimiter, the value resolver returns an empty list ([]) and not a list with two empty strings.

►WARNING◄ If the Regular expression? option is selected, syntax errors may occur when interpreting the regular expression defined in the Delimiter parameter, which are handled as ProcessException by default.

Configuration

The text to be split is expected as input value. If the input value is not text (String), the string image of the input value is used.

Parameter

Description

Example

Separator


By default, a text field is provided for the Delimiter for direct input of one or more text characters.

The example on the right specifies a string of three characters ' - ' (space, minus, space) as the delimiter, which has been selected in the screenshot to highlight the spaces.

An input value like 'New York - Rio - Tokyo' is converted by this Delimiter into a list of three substrings ('New York', 'Rio', 'Tokyo').

Direct input

images/download/attachments/62867074/image2023-1-4_12-1-21-version-1-modificationdate-1672830081740-api-v2.png

Clicking on the small gray arrow at the bottom left switches from direct entry to value configuration, so that a value resolver or a chain of value resolvers can be configured to dynamically assign the Delimiter at runtime.

In the example on the bottom right, a Value from localization value separator is used that refers to the Bundle lobsterui and the Resource thousandsSeparator. Obviously, the 'thousands separator' defined as localization (in the Localization or Company specific localization) for the Current locale is used as a Delimiter here.

An input value like '12.345.678' would be split into three substrings with digit groups ('12', '345', '678') in a session in the Locale 'German' (with default locale).

To achieve the same result in a session with the Locale 'English' (with default localization), the input value would have to be '12,345,678'.

Value configuration: (directly after switching, still without configuration)

images/download/attachments/62867074/image2023-1-4_12-1-55-version-1-modificationdate-1672830115596-api-v2.png

Example:

images/download/attachments/62867074/image2023-1-4_12-3-12-version-1-modificationdate-1672830192644-api-v2.png

Regular expression?

As long as the Regular expression? option is unchecked (default), input or resolved strings for the Delimiter parameter will be interpreted as plain text, as in the examples above.

If the Regular expression? option is checked, then input or resolved strings for the Delimiter parameter will be interpreted as a regular expression. If matches are found in the input value for the parameterized expression, the input value is divided at the respective place where it was found. The sections evaluated as Delimiters are not included in the returned substrings.

Example:

images/download/attachments/62867074/image2023-1-4_12-4-34-version-1-modificationdate-1672830274764-api-v2.png

The regular expression [,.'\s] defined by static direct input qualifies a set of separators to act as equal Delimiters.

The input values like '12,345,678' and '12,345,678' (see previous example) or also "12 345 678" und "12'345'678" are thereby divided into the always same three groups of digits.

NOTE◄ Since the \s character class covers all whitespace characters (not just the space character), a line break in the input value, for example, would also act as a Delimiter.

NOTE◄ Of course, the string for the Delimiter parameter can also be defined by value configuration (see above) if the Regular expression? option is checked. Therefore, the regular expression can be defined dynamically at runtime (via value resolvers).

Examples

Simple use case: 'Parse' list entries from comma-separated text

A comma-separated list of abbreviations for currencies should be able to be entered in a text field of an entity in order to list currencies that are 'accepted' in the context of the business process concerned.

  • For example, an entry like 'JPY,USD,EUR' should signal that Japanese Yen, US Dollar and Euro are 'acceptable'.

In the context of an event handling, the entered text is 'resolved' into a real list of single values, e.g. so that current exchange rates can be retrieved via a profile in the context of a loop.

In the Resolver for entities parameter of the Für jeden Eintrag wiederholen (Schleife) shown on the right, the Split text value resolver is used to split the text that is to be directly available here as an input value for the loop and therefore also the value resolver.

  • The comma (,) is selected as Delimiter by direct input.

  • The Regular expression? option is not checked.

In the action block, over which the loop iterates, a profile is called up that is supposed to call up the current exchange rate for the respective currency (e.g. via web service). For this purpose, the text key for the currency in question is required as a parameter. The further processing of the exchange rate data should not play a role here.

Runtime example:

An input value such as 'PY,USD,EUR' triggers an iteration over the listed individual values and thus three profile calls with changing text parameters ('JPY', 'USD', 'EUR').

NOTE◄ The Split text value resolver does not automatically 'trim' the substrings, so an input value like 'JPY, USD, EUR' (with space after the comma) could lead to difficulties unless the Trim value resolver is used in the profile call for the parameter.

images/download/attachments/62867074/image2023-1-4_12-5-38-version-1-modificationdate-1672830338646-api-v2.png

The variant shown on the right uses the Regular expression? option and the regular expression ',\s*' to define the Delimiter in such a way that all whitespace characters (spaces, line breaks) directly following the comma are interpreted (and therefore 'eliminated' or 'skipped') as part of the separator.

Runtime example: An input value like 'JPY,USD,EUR,CHF' returns the text keys 'JPY', 'USD', 'EUR' and 'CHF' in the iteration without unnecessary spaces.

NOTE◄ Spaces at the beginning and at the end of the comma-separated list are not eliminated by this procedure!

images/download/attachments/62867074/image2023-1-4_12-6-16-version-1-modificationdate-1672830377080-api-v2.png

More complex use case: 'Resolve' components of a phone number

The structure of a phone number in a text field is expected in the format <country code> (<area code>) <connection>[-<extension>].

In addition to digits, the individual components (<...>) of the phone number should also be allowed to contain spaces and, with regard to the country code, the plus sign (+).

In the context of event handling, these components are split and assigned to specific variables (countryCode, areaCode, line, extension).

The phone number to be split is passed as input value to the Für jeden Eintrag wiederholen (Schleife) shown on the right. For access within the loop it is stored in the phoneNumber variable.

  • The Resolver for entities here defines the variable names for the four components as a list of static text values (String[]) via a Create list value resolver.

  • In the action block for the iteration, the assignment to the Variable whose name is the reference object for the iteration is made via the Set value value resolver. The Object property value resolver in the Variable name parameter returns this name.

  • On the right side of the assignment, the phoneNumber variable is accessed to read out the component for the current iteration level through a value resolution chain:

    • The Split text value resolver returns the list of all (existing) components at each iteration. The [^+\d ] Delimiter is interpreted as a Regular expression which evaluates all characters as separators which are not (^) digits (\d) or explicitly specified in the bracket expression (space, +).

    • A different value is drawn from the result of the split at each iteration, which is identified in the concatenated List item value resolver by reference to the loop variable $index in the Offset parameter.

    • The final Trim value resolver removes marginal spaces for the component. These are qualified as non-separating characters in the regular expression for the Delimiter so that the digits of a component can be entered in a grouped manner (e.g. 32 16 8).

NOTE◄ Splitting the components works properly only under the assumption that the string in the phoneNumber variable does not 'skip' any component in the schema and only the extension at the end is optional specification.

NOTE◄ Considering performance, the Split text value resolver should be placed before the loop to write the list of components into a variable. Then the splitting does not have to be repeated with each iteration. With consideration for the clearer representation (right) here it was renounced.

images/download/attachments/62867074/image2023-1-4_12-7-30-version-1-modificationdate-1672830450326-api-v2.png

Runtime example: The following component variables are set with the input value '+49 (89) 12 52 - 3210':

Variable

Value

countryCode

+49

areaCode

89

line

12 52

extension

3210

Special use case: Process components from the string image of an entity

If there is no text as input value for the Split text value resolver, the string image of the input value is processed as the text to be split.

A string with the following structure is output for an entity:

  • <id>:<entityClass>@<objectId>

Runtime example: (String image for a user account with ID 1901)

  • 1901:de.lobster.scm.base.security.user.User@510285c7

To identify an entity in a way that is readable by a user, e.g. in a notification, the ID of the entity (<id>) and the class (<entityClass>) or the localization for the class name are usually used. The ID of the Java object (@<objectId>), on the other hand, usually plays no role.

The following example shows how the components of an entity's string image can be obtained and used to identify the entity (in this case, the User of session) in a notification.

The Ausführen mit event action shown already defines, via the Object resolver parameter as a reference object, the list of substrings obtained from the string image for the entity returned by the User of session:

  • The Delimiter parameter is to be interpreted as a Regular expression. It is defined as static text [@:]and classifies the characters @ und : as alternative separators.

  • In the action part, a Show alert event action accesses the substrings, which the Split text value resolver provides as a list (String[]):

    • The localization for the class name should appear in the Title. The Value from localization value resolver accesses the second substring in the input value (Offset 1) via a List item value resolver to address the Bundle for the entity for whose Resource $name the localization is to be obtained.

    • The Message itself shall only name the ID of the entity which can be read as the first substring in the input value over a List item value resolver with Offset 0.

Runtime examples:

images/download/attachments/62867074/image2023-1-4_12-20-19-version-1-modificationdate-1672831219983-api-v2.png

images/download/attachments/62867074/image2023-1-4_12-19-36-version-1-modificationdate-1672831176512-api-v2.png

NOTE◄ Of course, the type of account returned by the User of session interface could also be determined via the variable entityClass, which the system automatically fills depending on the reference object.

images/download/attachments/62867074/image2023-1-4_12-9-7-version-1-modificationdate-1672830548046-api-v2.png