I am use Google Cloud DLP (node.js) for redact phone number from string (this string can contain other word). https://cloud.google.com/dlp/docs/samples/dlp-inspect-phone-number
For example I want redact phone number in: Do transaction over phone to bypass fee. My number: 18776967786
But Cloud DLP only redact phone number with international format. For example +1-877-696-7786
Anyone know good method for iterate through string and redact possible phone number?
Thanks for help!
As mentioned by @Jordanna Chord, US_TOLLFREE_PHONE_NUMBER works as infotype for given example. And for phone numbers other than US, you can use PHONE_NUMBER as infotype.
Specifying redactConfig redacts a given value by removing it completely. The redactConfig message has no arguments; specifying it enables its transformation. Refer redactConfig for more information.
Redact a given value. For example, if used with an InfoTypeTransformation transforming PHONE_NUMBER, and input 'My phone number is 206-555-0123', the output would be 'My phone number is '. You can specify one or more infoType transformations per request. Within each InfoTypeTransformation object, you specify both of the following:
The challenge here is that if there's no context and no formatting, then a phone number may just look like a ~10 digit number. If you want to redact phone numbers you should mention the correct format. Or else, turn on redaction of PHONE_NUMBER and GENERIC_ID with a threshold of UNLIKELY to remove even if it is not mentioned in the format.
Example formats:
| Item | Result | Likelihood |
|---|---|---|
| 18776967786 | GENERIC_ID | UNLIKELY |
| 877-696-7786 | PHONE NUMBER | POSSIBLE |
| 877 696 7786 | PHONE NUMBER | POSSIBLE |
| +1 877 696 7786 | PHONE NUMBER | POSSIBLE |
| +18776967786 | PHONE NUMBER | POSSIBLE |