/build/static/layout/Breadcrumb_cap_w.png

How to define REGEX to find IPs (even vs odd) in Smart Label

I am trying to create two smart labels and I am wanting to limit them to certain IPs. Either Even or Odd. The first three octets will vary. Could be 10.x.x.x or 192.x.x.x. I am just looking at the last digit of the last octet. We had this set up a long time ago, and then those disappeared so I am trying to recreate them.

Any thoughts? Need more information?


0 Comments   [ + ] Show comments

Answers (5)

Posted by: rileyz 3 years ago
Red Belt
2

Ooo RegEx maths, I'm up for a challenge.

Try this for odds

\d{1,3}.\d{1,3}.\d{1,3}.\d*[13579]$


And this for evens

\d{1,3}.\d{1,3}.\d{1,3}.\d*[02468]$


Use this for testing sample data.

RegExr: Learn, Build, & Test RegEx



Posted by: flip1001 3 years ago
Black Belt
1

Even IP Smart Label
IP Address matches REGEX [0,2,4,6,8]$

Odd IP Smart Label
IP Address matches REGEX [1,3,5,7,9]$

Posted by: BHowell 3 years ago
Yellow Belt
0

Sorry for the delayed response. I didn't get a notification that I had responses to my question until today. Let me try these and report back. Thank you for the feedback. Will provide the results as soon as I can try them.

Posted by: BHowell 3 years ago
Yellow Belt
0

So I finally got the time to try this out and the good news is I got the desired results. Both of these solutions gave me the same information, but "flip1001" looked a little cleaner. Not saying what "rileyz" offered was wrong. I do wonder why the big difference between the two? Any thoughts on whether one has more applications than the other?

Posted by: BHowell 3 years ago
Yellow Belt
0


Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ