Extract Time Span

Extracts a time value from input text.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Extracts a time value, either in hours, minutes and/or seconds, expressed in specific text.

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

extractTimeSpan [--culture(String)] --text(String) (List<TimeSpan>)=values (TimeSpan)=first (DataTable)=valuesmapping (Boolean)=success

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Language culture Optional Text, Culture Language used to extract the time span.

If you define the language manually, make sure to enter only supported language codes. See the culture parameter options for supported languages.
Text text Required Text Input text containing time values, which can be hours, minutes and/or seconds.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Values values List<TimeSpan> Returns a list containing the time values (hours, minutes, and/or seconds) extracted from the input text.

The returned values are formatted according to the language defined in the Language parameter.
First value first Time Span Returns the first time value that is extracted from the input text.
Values mapping valuesmapping Data Table Data table with extracted values mapped by rows and columns.

See the valuesmapping parameter options section for details.
Success success Boolean Returns True if the extraction succeeds, or False otherwise.

culture parameter options

The following table displays the options available for the culture input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.

Designer mode label Script mode name Description
en-US en-US English
pt-BR pt-BR Portuguese (Brazil)
pt-PT pt-PT Portuguese (Portugal)

valuesmapping parameter options

This parameter returns a data table that contains the occurrence of each time span value that is extracted from the input text.

The following list shows the mapped values:

  • The index value in the list of extracted time spans. Index values start at 1.
  • Position in number of characters where the value was found in the text.
  • Length of the extracted value.
  • Text from which the time span was extracted.
  • Time span extracted.

Example

The following example demonstrates the use of the Extract Time Span command. The Extract Time Span command analyzes and extracts the time found in the input text, returning the values.

defVar --name valuesExtracted --type List --innertype TimeSpan
defVar --name firstValueFound --type TimeSpan
extractTimeSpan --culture en-US --text "My appointment will be held from 8 am to 12 noon on November 24." valuesExtracted=values firstValueFound=first
logMessage --message "Values ​​taken from statement: ${valuesExtracted}\r\nFirst value extracted: ${firstValueFound}\r\n" --type "Info"
// Return the following output in the console:
// Values ​​taken from statement: [08: 00: 00,12: 00: 00]
// First extracted value: 08:00:00

Limitations

This command does not support Watson NLP provider.