Jump to content

[SOLVED] hide last digits of ip


tyra

Recommended Posts

(?:[01]?\d\d?|2(?:[0-4]\d|5[0-5]))

 

this basically matches any number between 0 and 255, with the exception of like 001 which is also possible to see, akwardly enough, in an IP.

 

then, I attempt to match that same thing, but with a dot at the front, 2 times, since you just want to remove the last number.

 

(?:\.(?:[01]?\d\d?|2(?:[0-4]\d|5[0-5]))){2}

 

and then, the last one, is just another match from 0 - 255, with a word boundary expected \b to tell it to attempt all numbers, instead of match then exit

 

(?:[01]?\d\d?|2(?:[0-4]\d|5[0-5]))\b

 

the first 3 parts, I captured it in a backreference, then used it in the replacement $1.xxx, which translates in plain english, {First 3 Parts}.xxx

 

its regex, if you want to learn regex you should check out regexbuddy.com, they sell a product but they also give free regex tutorials.

 

goodluck tyra,

Russell :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.