Created 02-16-2017 05:03 PM
Hello,
We have a requirement to anonymize IP address. So we would identify IP address and replace the last part with some arbitrary value.
We have tried using the following regex for that (with "Regex Replace" for replacement strategy, "Line-by-Line" as evaluation mode)
(1) \\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}
(2) ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$
(3) ((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
None of this works.
Can you help me with the right value of regex we can use and the replacement value as well.
Thank you in advance!
Created on 02-16-2017 05:08 PM - edited 08-19-2019 04:24 AM
Try this with a ReplaceText processor:
Here is the complete Search Value property:
((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)).((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)).((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)).((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))
@anshuman Ghosh
Created 02-16-2017 05:06 PM
@Anshuman Ghosh I posted your question here for you.
Created on 02-16-2017 05:08 PM - edited 08-19-2019 04:24 AM
Try this with a ReplaceText processor:
Here is the complete Search Value property:
((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)).((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)).((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)).((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))
@anshuman Ghosh
Created 02-16-2017 05:11 PM
The Search Value Regex above has 4 capture groups from a valid IP address. Each capture group can then be referenced in the replacement Value as $1, $2, $3, and/or $4. In the example above the replacement for each found valid IP is still the first two numbers followed by ".x.x". You can of course change the replacement value to whatever meets your specific needs.
Thanks,
Matt