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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:25:46+00:00 2026-05-22T01:25:46+00:00

I would like to have a way to determine if an input is a

  • 0

I would like to have a way to determine if an input is a domain.

Example Inputs:

@stackexchange.com
@gmail.com
@google

Logic:

1. First determine if the first character is an @
2. If the input ends in a domain ext, .X or .XX or .XXX
3. Then determine if the domain (stackexchange, gmail, google) are not blacklisted. For example I might want to blacklist gmail.

Suggestions on how to go about doing this? Would this live in the controller or the model? Would Regex be the right way to do this or would that be to slow? Thanks

Ideas:

1. Use params[:q][0,1]
  • 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-22T01:25:46+00:00Added an answer on May 22, 2026 at 1:25 am

    Much like email addresses, a domain can appear to be correct, but fail the most basic test of not being a domain you can reach or connect to.

    You can check for the @ if you are looking for an email address, but that doesn’t tell you if it’s a domain. Domains don’t have @ signs.

    Domains have at least a single ., such as .com. They have a known TLD, aka Top-Level-Domain, which is the .com or .me or .info. The problem with TLDs is that they are being opened up to whatever people want them to be, so, soon, it will be difficult to do a simple lookup.

    In my opinion, your best bet is to try to connect to it via a ping, email and http connections. Those are the most likely services to be alive. A secondary choice would be to try to resolve the domain using something like this:

    host example.com
    

    which will return:

    example.com has address 192.0.32.10
    example.com has IPv6 address 2620:0:2d0:200::10
    

    Call it using %x{} or backticks.

    It might help to read the "Domain Name Syntax" description on Wikipedia for an overview on what defines a domain name, in particular:

    DNS names may technically consist of any character representable in an octet. However, the allowed formulation of domain names in the DNS root zone, and most other sub domains, uses a preferred format and character set. The characters allowed in a label are a subset of the ASCII character set, and includes the characters a through z, A through Z, digits 0 through 9, and the hyphen. This rule is known as the LDH rule (letters, digits, hyphen). Domain names are interpreted in case-independent manner. Labels may not start or end with a hyphen.

    RFC 3696 – Application Techniques for Checking and Transformation of Names will give you the full rules.

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

Sidebar

Related Questions

I would like to temporarily override the kill-new function. I have a way I
I have found the way to copy the record that I would like, but
I would like to know if there is a way in Android to have
I have a double value f and would like a way to nudge it
I have a String which I would like to modify in some way. For
I have a problem and i would like to learn the correct way to
What would be the best way to accomplish something like this? Suppose I have
If I have a json like follows, what would be the most efficient way
I would like to know the best way to determine if the following code
I would like to know if there is a clever/short way to determine if

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.