How does different properties of the "Change Text" block work
How does different properties of the "Change Text" block work
Introduction
The Change text building block changes a piece of text by applying an operation such as a “substring” (get a smaller piece of the text), “concatenate” (add two pieces of text together) among many others.
Text to Change
The original text to change (example: Leapwork). The text can be dynamic by using tokens for added fields (see below). Right-click in the text and select “Insert token” to insert a field that has been added below.
Text fields
Add any number of fields that can contain dynamic content and be used as tokens in the text.
Change Text Method
Method “substring”
Get a piece of text from within the original text. This method requires two sub-properties to be filled out:
- Index: The first character position in the text to start the substring operation from. (ex: 0).
- Count: The number of characters to get from the text (ex: 4).
Method “Replace”
Replace all occurrences of a piece of text with another piece of text. This method requires two sub-properties to be filled out:
- Old value: The value to find and replace in the text. (ex: work)
- New value: The value to replace the old value within the text. (ex: Test)
Method “Concat”
Concatenate (add) two pieces of text together. This method requires one sub-property to be filled out:
- Text: The text to concatenate (add) to the existing text. (ex: Automation)
Method “Uppercase”
Change all characters from the original text to UPPERCASE.
Method “Lowercase”
Change all characters from the original text to lowercase.
Method “Index of”
Within the original text, find the position of the first occurrence of a piece of text.
This method requires two sub-properties to be filled out:
- Subtext: The value to find the index of, in the text. (ex: work)
- Occurrence: The occurrence of the value to find the index of, in the text. (ex: 1)
Method “Last index of”
Within the original text, find the position of the last occurrence of a piece of text.
This method requires two sub-properties to be filled out:
- Subtext: The value to find the index of, in the text. (ex: "r")
- Occurrence: The occurrence of the value to find the index of, in the text, starting at the end and moving backward. (ex: 1)
Method “Length”
Count the number of characters in a piece of text.
Method “Trim”
Remove all of the whitespace, or other specific characters, from the start and end of a piece of text.
This method requires one sub-property to be filled out:
- Trim characters: One or more characters to trim from the text. (ex: work)
Method “Pad left”
Add specific padding characters to the left (front) of the text.
This method requires two sub-properties to be filled out:
- Pad characters: One or more characters to pad the existing text with, on the left side. (ex: Test)
- Length: The desired length of the text after padding. (ex: 12)
Method “Pad right”
Add specific padding characters to the right (end) of the text.
This method requires two sub-properties to be filled out:
- Pad characters: One or more characters to pad the existing text with, on the right side. (ex: Test)
- Length: The desired length of the text after padding. (ex: 12)
Result Text
The changed text is the result of the operation.
For any clarification, contact our Priority Support.