Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9116167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:36:24+00:00 2026-06-17T04:36:24+00:00

I have a textbox and the only input that it should take is either

  • 0

I have a textbox and the only input that it should take is either a single ip address or a range in the form of: 10.2.3.4-10

I have this so far:

string txt = "10.13.11.12-100";

        string re1 = "((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?![\\d])";   // IPv4 IP Address 1
        string re2 = ".*?"; // Non-greedy match on filler
        string re3 = @"\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b";//"([0-255])";   // Integer Number 1

        Regex r = new Regex(re1 + re2 + re3, RegexOptions.IgnoreCase | RegexOptions.Singleline);
        Regex r2 = new Regex(re1, RegexOptions.IgnoreCase | RegexOptions.Singleline);
        Match m = r.Match(txt);
        Match m3 = r2.Match(txt);
        if (m.Success || m3.Success)
        {...}

Only thing is with that, if I have 100.100.11.11-256 it will still return true since it matches m3.Success above as true.

How to fix that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:36:25+00:00Added an answer on June 17, 2026 at 4:36 am

    For the IP Range Regex:

    ^10.2.3.(?:[4-9]|10)$
    

    For the single IP address: Regular expression to match DNS hostname or IP Address?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox which is read-only. It is used to take input of
I have a textbox that accepts only these values: . , - $ m
I have a textbox that I would like for only numbers. But if I
i have a validation in my .net textbox where it will take only numbers
i have a validation in my .net textbox where it will take only numbers
I have used auto complete textbox previously. That auto complete works only when i
I have a form with text boxes that take (by default) a decimal value.
I have a WPF textbox on a form to allow input of a URI.
I have a TextBox that only allows certain characters to be typed into it;
I am wanting to have a numbers/currency only textbox control. So basically it should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.