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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:42:20+00:00 2026-05-30T08:42:20+00:00

I have a field in which I ask for desired domain name, now it

  • 0

I have a field in which I ask for desired domain name, now it came to a point that some user includes http://www.desireddomain on the field. Having this value, the domain registrar API I have will return an error. The approach I have in mind is to omit any characters before period (including period), using preg_replace(). I have a <select> which contains (.com,.biz,.org,.net)

$desired_domain = "www.desireddomain"; // user input
$will_be = "desireddomain"; // final output after preg_replace() ?

And also, does this limits me to only the period or is there anything more I should know? Thanks.

  • 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-30T08:42:21+00:00Added an answer on May 30, 2026 at 8:42 am

    You don’t need to use regular expressions since you are aren’t doing a “fuzzy” search. Just get everything from the last period on, if there is a period.

    if ( strrpos('www.domain','.')!==false ) {
        $domain = substr('www.domain',strrpos('www.domain','.')+1);
    }
    

    Alternatively, if you want to make sure they didn’t enter .com,.biz,.org,.net, use explode and do a check.

    $parts = explode('.', 'www.desireddomain.com.net');
    $domain = array_pop($parts);
    $invalid_parts = array('com','biz','org','net');
    if ( in_array($domain, $invalid_parts) && count($parts)>0 ) {
        $domain = array_pop($parts);
    } else {
        // No valid domain submitted
    }
    

    In this example, they are asking to use “com” as the domain, even though it’s no valid. You could create a loop instead, where you continuously pop items off the array until you find a valid part or run out of items.

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

Sidebar

Related Questions

I have a large table in SQL; one field contains the user's name, which
Let's say I have some class, TMaster, which asa field includes a TIdTCPServer. Some
i have an input field which will be displayed. i want that to hide
I have a model Token, which has a field token_number that I need to
I have a search field which basically gives the user a tip of what
I have several questions about the PE subsystem field, which may overlap to some
I have a form which, among the other controls, has a TextBox field that
I would like to have a field which is updated on every change(insertion, modification),
in my database we have a field which is going beyond int max value,
I use yui datatable and i have a field which is resumePath which is

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.