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 6943529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:10:05+00:00 2026-05-27T13:10:05+00:00

I have an application which must warn the user upon use of localhost ,

  • 0

I have an application which must warn the user upon use of localhost, 127.0.0.1, ::1, or any loopback address (the target host is used for a database-to-database connection not necessarily inside of the environment of the application). This is made complicated because addresses like the following…

  • 127.1
  • 127.0.01
  • 127.0000.0000.1
  • 127.0.0.254
  • 127.63.31.15
  • 127.255.255.254
  • 0::1
  • 0000::0001
  • 0000:0:0000::01
  • 0000:0000:0000:0000:0000:0000:0000:0001

…will parse properly by the consuming code, and will resolve to loopback.

What is a regular expression which will match any permutation of the IPv4 and IPv6 loopback addresses?

  • 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-05-27T13:10:06+00:00Added an answer on May 27, 2026 at 1:10 pm

    After a short time fiddling around in RegexBuddy (which is a truly magnificent tool for test-driven RegEx construction), I have come up with this:

    ^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$
    

    This RegEx matches

    The string “localhost”

    • localhost
    • LOCALHOST

    These permutations of the IPv4 loopback address

    • 127.0.0.1
    • 127.0.0.001
    • 127.0.00.1
    • 127.00.0.1
    • 127.000.000.001
    • 127.0000.0000.1
    • 127.0.01
    • 127.1
    • 127.001
    • 127.0.0.254
    • 127.63.31.15
    • 127.255.255.254

    These permutations of the IPv6 loopback address

    • 0:0:0:0:0:0:0:1
    • 0000:0000:0000:0000:0000:0000:0000:0001
    • ::1
    • 0::1
    • 0:0:0::1
    • 0000::0001
    • 0000:0:0000::0001
    • 0000:0:0000::1
    • 0::0:1

    This RegEx does not match

    A valid server name

    • servername
    • subdomain.domain.tld

    These valid IPv4 addresses

    • 192.168.0.1
    • 10.1.1.123

    These valid IPv6 addresses

    • 0001::1
    • dead:beef::1
    • ::dead:beef:1
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have gwt web project, which must use application.properties (on client side) loaded as
I have application which needs to use a dll (also written by me) which
We have an application which needs to use Direct3D. Specifically, it needs at least
I have a .Net application which must store all it's local data in isolated
I have an application which intensively uses DB (SQL Server). As it must have
I have Java application which adds JTextFields @ runtime to JPanel. Basically user clicks
My GWT application creates text areas, each of which must have an ID in
I have a multi-threaded application which needs to display certain dates to the user.
I have a combo in my UI application which must not be editable. In
I'm writing an Android application which requires the user to login. I have a

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.