解析 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

另请参阅

  • 向正则表达式添加转义字符
  • 向文本添加转义字符
  • 计算散列
  • 更改文本大小写
  • 检查文件
  • 并置文本
  • 将 HTML 转换为文本
  • 计算在文本中的出现次数
  • 文本字符计数
  • 创建随机文本
  • 通过正则表达式创建表
  • 空文本变量或 Null 文本变量
  • 通过正则表达式查找
  • 在文本中查找出现项
  • 设置文本格式
  • 获取子文本
  • 通过正则表达式获取文本
  • HTML 转换为 Markdown
  • 向文本插入新行
  • 连接文本
  • 填充文本
  • 除去变音符号
  • 除去转义字符
  • 替换部分文本
  • 替换文本
  • 拆分文本
  • 修剪文本空白