通过正则表达式创建表

动词:getRegexTable

可从以下位置获取: <Standard>

使用包含正则表达式的文本来创建数据表。

语法

getRegexTable --text(String) --regexPattern(String) [--regexOptions(DisplayableRegexOptions)] (DataTable)=value (Numeric)=rows (Numeric)=columns

输入

脚本 设计器 必需的 AcceptedTypes Description
-- 文本 文本 必需的 文本 用于创建数据表的文本。
--regexPattern 正则表达式 必需的 文本 用于映射数据表值的正则表达式。
--regexOptions 选项 可选 可显示的正则表达式选项 正则表达式选项包括:
  • 已编译
  • 区域设置不变量
  • ECMA 脚本
  • 显式捕获
  • 忽略大小写
  • 忽略模式空格
  • 多行
  • 从右到左
  • 单行
  • 输出

    脚本 设计器 AcceptedTypes Description
    数据表 根据文本正则表达式创建的数据表。
    成员 命令执行中影响的行数。
    columns 列数 成员 命令执行中影响的列数。

    示例

    使用正则表达式 "Name: (.+?)Security Number:\\s(\\d{11})" 创建基于在 Text 参数中输入的文本的数据表,以获取人员的姓名和社会保险号。

    defVar --name dataTable --type DataTable
    defVar --name amountLines --type Numeric
    defVar --name columnCount --type Numeric
    defVar --name currentLine --type Numeric
    defVar --name IndexColumn --type String
    defVar --name columnValue --type String
    defVar --name column0 --type String
    defVar --name column0Index --type String
    defVar --name columnN1 --type String
    defVar --name columnN1Index --type String
    defVar --name columnN2 --type String
    defVar --name columnN2Index --type String
    // Create the data table based on the regular expression "Name: (. +?) CPF: \\ s (\\ d {11})".
    getRegexTable --text "Name: Ana Alves Social Security Number: 22134567891, Name: Juliana Sanchez Social Security Number: 12332134554, Name: Paulo Lima Social Security Number: 45667878998, Name: Carlos Souza Social Security Number: 34567889000" --regexPattern "Name:(.+?)Social Security Number:\\s(\\d{11})" --regexOptions "Singleline" amountLines=rows columnCount=columns dataTable=value
    logMessage --message "INDEX | VALUE | 0 | 0_INDEX | 1 | 1_INDEX | 2 | 2_INDEX" --type "Info"
    for --variable ${currentLine} --from 1 --to ${dataTable.Rows} --step 1
    // Maps and displays the values of the current table row
       mapTableRow --dataTable ${dataTable} --row ${currentLine} --mappings "number=1=${IndexColumn},number=2=${columnValue},number=3=${column0},number=4=${column0Index},number=5=${columnN1},number=6=${columnN1Index},number=7=${columnN2},number=8=${columnN2Index}"
       logMessage --message "${IndexColumn} | ${columnValue} | ${column0} | ${column0Index} | ${columnN1} | ${columnN1Index} | ${columnN2} | ${columnN2Index}" --type "Info"
    next
    logMessage --message "\r\nColumns affected: ${columnCount}\r\nLines affected: ${amountLines}" --type "Info"
    // This example produces the following result:
    // INDEX | VALUE | 0 | 0_INDEX | 1 | 1_INDEX | 2 | 2_INDEX
    // 0 | Name: Ana Alves Social Security Number: 22134567891 | Name: Ana Alves Social Security Number: 22134567891 | 0 |  Ana Alves  | 5 | 22134567891 | 40
    // 53 | Name: Juliana Sanchez Social Security Number: 12332134554 | Name: Juliana Sanchez Social Security Number: 12332134554 | 53 |  Juliana Sanchez  | 58 | 12332134554 | 99
    // 112 | Name: Paulo Lima Social Security Number: 45667878998 | Name: Paulo Lima Social Security Number: 45667878998 | 112 |  Paulo Lima  | 117 | 45667878998 | 153
    // 166 | Name: Carlos Souza Social Security Number: 34567889000 | Name: Carlos Souza Social Security Number: 34567889000 | 166 |  Carlos Souza  | 171 | 34567889000 | 209
    // Columns affected: 8
    // Lines affected: 4
    

    备注

    映射信息后,此命令遵循用于拆分中信息的以下规则,返回行数列数

  • 第一列是索引,用于描述通过正则表达式获取的全局模式在文本中的开始位置。
  • 第二列是通过正则表达式获取的全局匹配项的值。
  • 后续列基于部分匹配的值并遵循以下规则:

  • 列“0”对应于全局正则表达式匹配项。
  • 列“0_index”对应于全局匹配项的位置索引。
  • 列 N(其中 N 为整数)对应于正则表达式中的其他任何匹配项。
  • 列“N_index”对应于列 N 中匹配的表达式在文本中的位置索引。
  • 另请参阅

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