Hi,
Utilizing the 2025.1 Data Masking Capability to Mask All but the Last 4 Characters
We had a requirement to mask several attributes while always leaving the last four characters visible. For example:
The Challenge
The attribute values varied in length, which made it tricky to use standard masking options:
-
First "N" Masked:
-
Last "N" Masked:
Neither of these options met our requirement, as the first option masked inconsistently based on length, and the last option hid the critical trailing characters.
The Solution
We leveraged the Custom Masking option with a regular expression to precisely control what remained visible. The configuration looked like this:
Step-by-Step Configuration
-
Access the Data Masking Settings:
-
Create a New Masking Rule:
-
Select the Custom Masking Option:
-
Set Up the Regular Expression:
-
Configure Masking Behavior:
-
Set Masked Match Part to False
to keep the matched portion (last 4 characters) visible.
-
Define your mask character (e.g., *
) or leave the default.
-
Apply the Rule to Attributes:
-
Test the Masking Rule:
-
Save and Deploy:
------------------------------
Varsha Periyasamy
MDM Developer
Majix Solutions Inc
------------------------------
Original Message:
Sent: 02-28-2025 13:42
From: Wes Corbin
Subject: Utilizing the 2025.1 Data Masking capablity to mask all but the last 4 characters
We had a requirement to mask several attributes where the mask should always leave the least four characters visible like this
- String: 123456789
- Masked: *****6789
However, we ran into a scenario where a string could vary in length within the same attribute. This meant the standard masking option First "N" left more than four characters unmasked as the initial length increased, and the Last "N" option provided the opposite of the desired result:
- First 5 Masked:
- String: 123456789
- String: 1234567890
- Last 4 Masked
To meet our requirement, we used the Custom Masking option with the regular expression ".{4}$" and "Masked match part" set to false, like this in the UI:

The preview shows that the last four characters are left unmasked, and this can be directly validated with inputs of various lengths.
The JSON config would be like this:
"masking": { "regexPattern": ".{4}$", "maskMatched": false}
The "4" in the curly braces determines how many characters are left unmasked and can be updated per requirement.
Hope this helps others.
------------------------------
Thanks,
Wes Corbin
Wex Inc
Portland ME
------------------------------