Results 1 to 5 of 5

Thread: IP range and Regular Expressions - Have I got this right?

  1. #1
    Flower Child stytagm's Avatar
    Join Date
    Aug 2004
    Location
    London
    Posts
    754
    Thanks
    47
    Thanked
    23 times in 18 posts

    IP range and Regular Expressions - Have I got this right?

    Hi All,

    I'm trying to filter out an IP range from my analytics package, but I'm hopeless with this sort of stuff, does this look right?

    The range was given to me as: 194.153.105.0/23 Which I think translates to the range 194.153.105.0 to 194.153.109.255, is that correct? (Calculated using this page: http://jodies.de/ipcalc)

    Next, I came up with this regular expression: (Edit: Based on this page: http://www.webmasterworld.com/analytics/3011116.htm)
    ^194\.153\.10([5-9])\.([0-9]¦1[0-9]¦2[0-9]¦3[0-9]¦4[0-9]¦5[0-9]¦6[0-9]¦7[0-9]¦8[0-9]¦9[0-9]¦1[0-9][0-9]¦2[0-4][0-9]¦25[0-5])

    Does that look right? Unfortunately there's no real way of testing it, as I can't ping my analytics from specific IPs in the range, and I have no way of knowing if traffic outside this range is being filtered out that shouldn't.

    Many thanks for your help guys,
    Andrew.

    PS I've actually changed this number from the real one because I'm paranoid, but it shouldn't affect the regex. (I only changed the first two octets)
    Last edited by stytagm; 25-07-2007 at 10:15 AM. Reason: Rememebred link
    They told me I was gullible ... and I believed them.

  2. #2
    Flower Child stytagm's Avatar
    Join Date
    Aug 2004
    Location
    London
    Posts
    754
    Thanks
    47
    Thanked
    23 times in 18 posts
    Ok well I spotted one mistake myself, I was given 194.153.108.0/23 so the range should be 194.153.108.0 to 194.153.109.255

    So the regex should be
    ^194\.153\.10([8-9])\.([0-9]¦1[0-9]¦2[0-9]¦3[0-9]¦4[0-9]¦5[0-9]¦6[0-9]¦7[0-9]¦8[0-9]¦9[0-9]¦1[0-9][0-9]¦2[0-4][0-9]¦25[0-5])
    They told me I was gullible ... and I believed them.

  3. #3
    TiG
    TiG is offline
    Walk a mile in other peoples shoes...
    Join Date
    Jul 2003
    Location
    Questioning it all
    Posts
    6,213
    Thanks
    43
    Thanked
    47 times in 42 posts
    If you are filtering it out you don't need to be clever with the last section.

    Filter out the three first octets, doesn't matter what is contained in the last if its 194.153.108/9

    TiG
    -- Hexus Meets Rock! --

  4. Received thanks from:

    stytagm (25-07-2007)

  5. #4
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    Code:
    194\.153\.10[5-9]\.*
    Keep it simple, if you're only filtering through IPs this is more than fine.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  6. Received thanks from:

    stytagm (25-07-2007)

  7. #5
    Flower Child stytagm's Avatar
    Join Date
    Aug 2004
    Location
    London
    Posts
    754
    Thanks
    47
    Thanked
    23 times in 18 posts
    Thanks guys, I've gone with:
    Code:
    ^194\.153\.10[8-9]\.*
    Assuming I got the range right in the first place this should do the trick.
    They told me I was gullible ... and I believed them.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •