Jump to content

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 :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.