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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:12:09+00:00 2026-06-13T10:12:09+00:00

I wrote method to detect if the hostname inside :email exists in an array

  • 0

I wrote method to detect if the hostname inside :email exists in an array of blacklisted hostname’s to no avail I have the method almost working but can’t figure it out:

host = email.split("@").last // e.g. "hotmail.com"
bad_hostnames = %w(rtrtr.com )

if /.*(#{bad_hostnames.join("|")}).*\@/.match(host)
  errors.add(:email, "Invalid temp mail provider")
end

What am I missing here? The regex is hard to test. Seems that the dot is causing issues, a similar method to check for certain blacklisted words in emails is working fine.

  • 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-13T10:12:10+00:00Added an answer on June 13, 2026 at 10:12 am

    I believe you are looking for this code:

    if /^(#{bad_hostnames.join("|")})$/.match(host)
    

    or this one:

    if /\@(#{bad_hostnames.join("|")})$/.match(email)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have wrote a method to convert any layout Liner,Relative,Frame etc into Bitmap but
I wrote this method to check if a page exists or not: protected bool
I have and old(ish) C# method I wrote that takes a number and converts
I wrote a custom ordering LINQ extension method as below but I think it
How would you write a method to detect if the mouse cursor is inside
I wrote a method that extracts fields from an object like this: private static
Question: I wrote a method to retrieve a SQL result as a list of
So I wrote a method to just get a database table and it returns
I'm having trouble with a method I wrote to insert string words into a
Hello StackOverflow community, Using Google App Engine, I wrote a keyToSha256() method within 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.