Description Details

Applicable to

All, although you cannot apply the Regex Replace Attributes advice directly to a System for Cross-domain Identity Management (SCIM) search.

Additional information

The payload for this advice is either a JSON object or an array of JSON objects. Each object represents a single replacement operation and has up to four keys.

Key Description

"regex"

Required.

Represents the regular expression to use to find the attribute values to replace.

"replace"

Required.

Represents the regex replacement string to use to replace the attribute values with a new value.

"path"

Optional.

Is a JSONPath expression that represents the nodes to start searching under.

"flags"

Optional.

Is a string that contains the regex flags to use.

Recognized flags are:

  • "i"

    Performs case-insensitive matching.

  • "l"

    Treats the "regex" value as a literal string.

  • "c"

    Performs "canonical equivalence" matching.

You can combine flags. For example: "il"

PingAuthorize replaces any portion of the attribute value that matches the regular expression in the "regex" value in accordance with the "replace" replacement string. If multiple substrings within the attribute value match the regular expression, PingAuthorize replaces all occurrences.

The regular expression and replacement string must be valid as described in the API documentation for the java.util.regex.Pattern class, including support for capture groups.

For example, consider the following body.

{
   "id":5,
   "username":"jsmith",
   "description":"Has a registered ID number of '123-45-6789'.",
   "secrets":{
      "description":"Has an SSN of '987-65-4321'."
   }
}

Also, consider the following payload.

{
   "path":"$.secrets",
   "regex":"\\\\d{3}-\\\\d{2}-(\\\\d{4})",
   "replace":"XXX-XX-$1"
}

Applying the advice produces the following body with a changed "secrets.description" value.

{
   "id":5,
   "username":"jsmith",
   "description":"Has a registered ID number of '123-45-6789'.",
   "secrets":{
      "description":"Has an SSN of 'XXX-XX-4321'."
   }
}