Create Table By Regular Expression

Verb: getRegexTable

Available from: <Standard>

Creates a data table using a text with a regular expression.

Syntax

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

Inputs

Script Designer Required AcceptedTypes Description
--text Text Required Text Text used to create the data table.
--regexPattern Regular expression Required Text Regular expression used to map data table values.
--regexOptions Options Optional DisplayableRegexOptions Regular expression options:
  • Compiled
  • Culture Invariant
  • ECMA Script
  • Explicit Capture
  • Ignore Case
  • Ignore Pattern Whitespace
  • Multiline
  • Right To Left
  • Singleline
  • Outputs

    Script Designer AcceptedTypes Description
    value Table Data Table Data table created from the Text and the Regular expression .
    rows Rows Number Amount of lines affected in command execution.
    columns Columns Number Amount of columns affected in command execution.

    Example

    Creates a data table based on the text entered in the Text parameter using the regular expression "Name: (.+?)Security Number:\\s(\\d{11})" to get a person's name and social security number.

    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
    

    Remarks

    After mapping the information, the command returns Table, Rows, and Columns, following the rules below for splitting the information in the Table:

  • The first column is the index that describes the position where the global pattern obtained by the regular expression starts in the text.
  • The second column is the value of the global match obtained by the regular expression.
  • The following columns are based on values that partially match, following these rules:

  • Column "0" corresponds to the global regular expression match.
  • Column "0_index" corresponds to the position index where the global match is located.
  • Column N, where N is an integer, correspond to any other matches in the regular expression.
  • Column "N_index", correspond to the position index where the matched expression in Column N is located in the text.
  • See Also

  • Add Escape Characters to Regular Expression
  • Add Escape Characters to Text
  • Calculate Hash
  • Change Text Case
  • Check File
  • Concatenate Texts
  • Convert HTML to Text
  • Count Occurrences in Text
  • Count Text Characters
  • Create Random Text
  • Empty or Null Text Variable
  • Find by Regular Expression
  • Find Occurrences in Text
  • Format Text
  • Get Subtext
  • Get Text from Regular Expression
  • HTML to Markdown
  • Insert New Line to Text
  • Join Text
  • Pad Text
  • Parse URI
  • Remove Diacritics
  • Remove Escape Characters
  • Replace Part of Text
  • Replace Text
  • Split Text
  • Trim Text Blanks