#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0

    Need regex for populating IP address urgently


    Hi, I work on logs and hence require a common regex for the below cases:

    '(192.168.136.70
    '192.168.136.70:

    I need a common regex to display any of the above IPs

    Also help me in writing a regex to display 37975 in
    '192.168.136.70:37975'
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    Iam new to this but you can try
    Code:
    Removed as it was incorrect
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0
    I dont need it any of the scripts.. I just need the regex..
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    '192.168.136.70[:]{0,1}\Z'

    Try this, as I said I am new to this, do make sure about it before using.

    - AJ
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0
    Hi, thanks for your help and it worked.

    Can you please help me map the last 5 digits in this IP??
    '192.168.136.70:37975'
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Location
    Paris area, France
    Posts
    843
    Rep Power
    496
    Try this (untested):

    Code:
    /(:?(:?\d){1-3}\.){3}(:?\d){1-3}:(\d){5}/
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    Bonn, Germany
    Posts
    35
    Rep Power
    3
    For matching IP addresses in general, you might want to have a look at my article about regex and IP, which I finished today. It also covers IPv6 by the way.

IMN logo majestic logo threadwatch logo seochat tools logo