Regex replace

Supported in: Batch, Streaming

Replace a string using a regex pattern.

Expression categories: Regex, String

Declared arguments

  • Expression - Input string to replace.
    Expression<String>
  • Pattern - The regex pattern to match.
    Expression<String>
  • Replace - Replacement string.
    Expression<String>

Output type: String

Examples

Example 1: Base case

Argument values:

  • Expression: tail_number
  • Pattern: (\w\w)(-)
  • Replace: **-
tail_numberOutput
MT-123**-123
XB-434**-434
MT-123, XB-434**-123, **-434

Example 2: Base case

Argument values:

  • Expression: tail_number
  • Pattern: (\w\w)(-)
  • Replace: $1
tail_numberOutput
MT-123MT123
XB-434XB434
MT-123, XB-434MT123, XB434

Example 3: Null case

Argument values:

  • Expression: tail_number
  • Pattern: regex
  • Replace: foo
tail_numberregexOutput
MT-123(null

Example 4: Null case

Description: Null inputs give null outputs. Argument values:

  • Expression: null
  • Pattern: (\w\w)(-)
  • Replace: **

Output: null


Example 5: Null case

Description: Null inputs give null outputs. Argument values:

  • Expression: foo
  • Pattern: bar
  • Replace: null

Output: null