Substring action
- 版本:
- 已更新: 2022/11/23
Substring action
The Substring action in the String package enables you to extract a substring from a string.
Settings
- In the Source string field, specify the source string.
- In the Start from field, specify the starting point.
- In the Length field, specify the length.
- Select the Return blank if the range is not found option to
have the output to show a blank value when the value in the Start
from index field is greater than the source string.Note: The index count starts from 1.
- In the Assign the output to variable list, specify the variable.
Example
Before you start building a bot, create a file in .txt format and save it as extract_substring.txt in the C:\Bot testing folder. Open the extract_substring.txt file and enter the text: Welcome to the Automation 360 platform and save it.
Create a sample bot and perform the
following steps to extract a substring from a source string:
- Create a bot.
- On the left panel, click Automation.
A list of available bots and forms is displayed.
- Click Create a bot.
- Enter the bot name: String_assign.
- Click Create and Edit.
- On the left panel, click Automation.
- Open and read data from the .txt file.
- Double-click or drag the action.Note: The session name will be set to default.
- In the File path field, select the Desktop file option and click Browse to select your file.
- In the Delimiter tab, select the Comma check box.
- Double-click or drag the action.
- In the Assign value to the variable field, click the Create variable icon to create a variable.
- On the Create variable window, enter table_data in the Name field.
- Click Create and select.
- Double-click or drag the action to close the .txt file.
- In the Session name field, enter the session name that you used in the Open action to open the file.
- Double-click or drag the action.
- To extract a substring from the source string, double-click or
drag the action.
- In the Source string field, select $table_data[0][0]$.
- In the Start from field, enter 16.
- In the Length field, enter 14.
- In the Assign the output to variable field, click the Create variable icon to create a variable.
- On the Create variable window, enter substring_output in the Name field.
- Click Create and select.
- To print the values, double-click or drag the Message box action. In the Enter the message to display field, enter $substring_output$.
- Click Save and then
Run.
The bot extracts the specific substring from the source string and displays the output as Automation 360.