Open sibmaks opened 2 years ago
If you need to split a string into two parts by any character or substring, it is useful to have these functions.
Transform json from:
{ "email": "user@domain.com" }
To
{ "email": "u***@domain.com" }
[ { "operation": "modify-overwrite-beta", "spec": { "emailLength": "=size(@(1,email))", "emailParts": "=split('@', @(1,email))", "userNameLength": "=size(@(1,emailParts[0]))", "userNameSub": "=substring(@(1,email), 0, 1)", "domainPart": "=substring(@(1,email), @(1,userNameLength), @(1,emailLength))", "email": "=concat(@(1,userNameSub), '***', @(1,domainPart))" } }, { "operation": "remove", "spec": { "emailLength": "", "emailParts": "", "userNameLength": "", "userNameSub": "", "domainPart": "" } } ]
[ { "operation": "modify-overwrite-beta", "spec": { "emailLength": "=size(@(1,email))", "dividerIndex": "=indexOf(@(1,email), '@')", "userNameSub": "=substring(@(1,email), 0, 1)", "domainPart": "=substring(@(1,email), @(1,dividerIndex), @(1,emailLength))", "email": "=concat(@(1,userNameSub), '***', @(1,domainPart))" } }, { "operation": "remove", "spec": { "emailLength": "", "dividerIndex": "", "userNameSub": "", "domainPart": "" } } ]
Use case for these functions:
If you need to split a string into two parts by any character or substring, it is useful to have these functions.
Masking email exmaple
Transform json from:
To
Current solution
With indexOf