解析 URI
动词:parseUri
解析是否文本对应于有效的 URI 地址。
URI 是“Uniform Resource Identifier”(统一资源标识)的首字母缩写。 这是一个精简字符串,用于标识或命名因特网中的资源,从而允许通过网络与资源表示进行交互。
语法
parseUri --text(String) (Boolean)=success (Uri)=value
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | Description |
|---|---|---|---|---|
| -- 文本 | 文本 | 必需的 | 文本 | 包含要解析的地址的文本。 |
输出
| 脚本 | 设计器 | AcceptedTypes | Description |
|---|---|---|---|
| 成功 | 成功 | BOOLEAN | 如果文本参数中插入的地址与有效的 URI 地址匹配,那么返回“True”;否则,返回“False”。 |
| 值 | URI | URI | 解析的文本中的数据。 |
示例
示例 1: 命令会评估地址 "https://www.ibm.com" 是否与有效 URI 地址匹配,并返回 URI 内容和地址的有效性 (在本例中为 "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
示例 2:使用此命令评估地址“nothing / nothing / nothing.nothing”是否对应于有效的 URI 地址,并返回 URI 内容以及地址的有效性,在本例中地址有效性为“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:
示例 3:使用获取系统文件夹路径命令从 Windows 操作系统中获取“文档”文件夹。然后,使用解析 URI 命令评估此文件夹的地址是否为有效的 URI,并返回 URI 内容以及地址的有效性,在本例中地址有效性为“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