i'm working on haiku sharing site , i'd able star out ip address segments anonymize submission data before it's shown other users.
if needed regexp satisfied following:
24.210.99.1 becomes 24.210.*.*
is there simple way accomplish it?
considering your comment:
it appear ip string because taking directly request headers. anticipating format #.#.#.# (standard ipv4) trick.
you may remove 2 last .+digits sequences , append .*.*:
var s = '24.210.99.1'; console.log(s.replace(/(?:\.\d+){2}$/, '') + ".*.*"); pattern explanation:
(?:\.\d+){2}- 2 ({2}) sequences of:\.- literal dot symbol\d+- 1 or more digits
$- end of string.
Comments
Post a Comment