Skip to main content
This gem runs in .

Overview

The Regex gem enables pattern matching and text extraction using regular expressions. This gem provides four distinct output methods for processing text data:

Prerequisites

  • Add prophecy_basics package version 1.0.0 or higher to your project.

Input and Output

The Regex gem uses the following ports:

Parameters

Configure the Regex gem using the following parameters.

Common configuration

These parameters are available for all regex operations:

Replace configuration

The Replace method substitutes matched portions of text with specified replacement values. When using this method, the gem outputs an additional column with the replaced values.

Example

Use this method to standardize phone number formats from 555-123-4567 to (555) 123-4567.
  • Select Column to Split: phone_number
  • Regex: (\d{3})-(\d{3})-(\d{4})
  • Replacement text: ($1)$2-$3 This inserts capture groups 1, 2, and 3 into the replacement pattern to create the new formatted string. The result is written to a new output column, while the original value is preserved.
Input table
Output table

Tokenize configuration

The Tokenize method splits text into tokens based on regex patterns and capture groups. Each capture group becomes a token. This method creates either new columns or rows depending on your configuration.

Example

Use this method to parse email addresses into username and domain components.
  • Select Column to Split: email
  • Regex: ([^@]+)@(.+)
  • Select Split Strategy: Split to columns
  • Number of columns: 2
  • Output root name: token
Input table
Output table

Parse configuration

The Parse method extracts capture groups from regex matches and outputs each group as a separate column. Prophecy automatically generates one output column for every capture group in the regex.
Rows in the Parse Configuration table are determined by the number of capture groups in the Regex field. You cannot add additional rows to or remove rows from this table.

Example

Use this method to parse phone numbers into area_code, exchange, and number columns.
  • Select Column to Split: phone_number
  • Regex: ([0-9]{3})-([0-9]{3})-([0-9]{4})
  • Parse Configuration:
Input table
Output table

Match configuration

The Match method determines whether text matches the specified regex pattern. Adds a column with 1 for matches and 0 for non-matches.

Example

Use this method to validate email addresses and create a binary match column.
  • Select Column to Split: email
  • Regex: ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$
  • Column name for match status: is_valid_email
  • Error if not matched: Disabled
Input table
Output table