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?
Answers (5)
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
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?