Parse URI
Verb: parseUri
Parses whether the text corresponds to a valid URI address.
URI stands for "Uniform Resource Identifier". It is a compact string used for identifying or naming a resource within the Internet, allowing interaction with resource representations over a network.
Syntax
parseUri --text(String) (Boolean)=success (Uri)=value
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--text | Text | Required | Text | Text with the address to be parsed. |
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
success | Success | Boolean | Returns "True" if the address inserted in the Text parameter matches a valid URI address; otherwise returns "False". |
value | URI | Uri | Data from the Text parsed. |
Example
Example 1: Command evaluates whether the address "https://www.ibm.com" matches a valid URI address, returning the URI content and the validity of the address, which in this case is "True".
defVar --name parseSuccess --type Boolean
defVar --name uriContent --type Uri
// Evaluate if the address "https://www.ibm.com" matches a valid URI address.
parseUri --text "https://www.ibm.com" uriContent=value parseSuccess=success
logMessage --message "\r\nsuccess: ${parseSuccess}\r\nURI: ${uriContent}" --type "Info"
// After script execution, the result is:
// success: True
// URI: https://www.ibm.com
Example 2: Command evaluates whether the address "nothing / nothing / nothing.nothing" corresponds to a valid URI address, returning the URI content and the validity of the address, which in this case is "False".
defVar --name parseSuccess --type Boolean
defVar --name uriContent --type Uri
// Evaluates if the address "nothing/nothing/nothing.nothing" matches a valid URI address.
parseUri --text "nothing/nothing/nothing.nothing" uriContent=value parseSuccess=success
logMessage --message "\r\nsuccess: ${parseSuccess}\r\nURI: ${uriContent}" --type "Info"
// After script execution, the result is:
// success: False
// URI:
Example 3: The Get System Folder Path command is used to get the "Documents" folder from the Windows operating system, and the Parse URI command to evaluate if the address for this folder is a valid URI, returning the URI content and the validity of the address, which in this case is "True".
defVar --name folderPath --type String
defVar --name parseSuccess --type Boolean
defVar --name uriContent --type Uri
getSpecialFolder --folder "MyDocuments" folderPath=value
// Evaluate the path of the "Documents" folder, making sure it is a valid URI address.
parseUri --text "${folderPath}" uriContent=value parseSuccess=success
logMessage --message "\r\nsuccess: ${parseSuccess}\r\nURI: ${uriContent}" --type "Info"
// After script execution, the result is:
// success: True
// URI: file:///[path to the system documents folder]/Documents