How do i generate Ip addresses from Regular Expression

Posted on 2008-11-17
Last Modified: 2012-05-05
I am getting Regular Expression as an input for IP Address. ex. 192.168.(2[0-4]\d|25[0-5]|[01]?\d\d?).\.(2[0-4]\d|25[0-5]|[01]?\d\d?). Having this, i need to generate list of IP Addresses starting from to How could i achieve this in C#.NET.

Could anybody help?

Thanks in advance..
Question by:Loganathan Natarajan
    LVL 27

    Expert Comment

    You would need to loop through the target addresses to test each one against your pattern to determine a match.  Another option would be to have all IP addresses in a text file in which you match each line against the pattern.  There really isn't a simple function to do this well that I am aware of, what is the goal?

    Note that . chars need to be escaped in regex patterns, as you did in one place but not the others, also in the one place where you did escape the . you seem to have an extra unescaped . before it.
    LVL 36

    Author Comment

    by:Loganathan Natarajan
    I am doing a program that will fetch the name of the computers available over a network. In order to get the computer name i need to provide the Ip address. There are many subnets available over the network. It is very difficult to enter all the IP addresses.
    So, i thought i could use Regular Expression to avoid this difficulty.
    I thought this could be generalized and used for any network.
    LVL 27

    Accepted Solution

    I would recommend you consider a pre-made module for this, if you can intergrate Perl in your solution there are subnet and IP matching modules available:
    LVL 27

    Expert Comment

    Thanks for the question and the points.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
    Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now