Array Regex Mask (ArrayRegexMaskGenerator)

The Array Regex Mask generator is a version of the Regex Mask generator that can be used for array values.

It uses regular expressions to parse strings and replace specified substrings with the output of specified generators. The parts of the string to replace are specified inside unnamed top-level capture groups.

In the Array Regex Mask generator, each link object identifies a regular expression and the generators to apply to the resulting capture groups.

The generator does not in itself support consistency or allow you to configure differential privacy.

The metadata object for each link object is populated from the RegexMaskMetadata object, and includes:

  • Whether to replace all matches or only the first match.

  • The regular expression used to identify the capture groups to replace.

  • The list of generator types to apply to each capture group. The first sub-generator is applied to the first capture group, the second generator to the second group, and so on.

  • In the captureGroupMetadata object, the configuration for each generator in captureGroupSubGenerators. The sequence of the entries in captureGroupMetadata must match the sequence of the generators in captureGroupSubGenerators.

{
  "schema": "string",
  "table": "string",
  "column": "string",
  "metadata": {
    "generatorId": "ArrayRegexMaskGenerator",
    "presetId": "ArrayRegexMaskGenerator",
    "replaceAllMatches": boolean,
    "pattern": "string",
    "captureGroupMetadata": [
      {
              //Metadata for a capture group generator
      }
    ]
  }
}

Example replacement

The following example provides a regex pattern that produces a single capture group.

For that capture group, the Constant generator is applied. The capture group value is replaced with test_value.

{
  "name": "character_col",
  "schema": "public",
  "table": "my_table",
  "links": [
    {
      "schema": "public",
      "table": "my_table",
      "column": "array_value",
      "metadata": {
        "generatorId": "ArrayRegexMaskGenerator",
        "presetId": "ArrayRegexMaskGenerator",
        "replaceAllMatches": true,
        "pattern": "(.*)",
        "captureGroupMetadata": [
          {
            "generatorId": "ConstantGenerator",
            "constant": "test_value"
          }
        ]
      }
    }
  ]
}

Last updated