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

  • Home
  • SEARCH
  • 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 8891783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:49:44+00:00 2026-06-14T22:49:44+00:00

I need to validate the facebook page url which should not consider http/https or

  • 0

I need to validate the facebook page url which should not consider http/https or www given or not?

I mean the following should be accepted or valid:

www.facebook.com/ABCDE
facebook.com/ABCDE
http://www.facebook.com/ABCDE
https://www.facebook.com/ABCDE

And following should not be accepted or invalid:

http://www.facebook.com/   => User name/page name not given
http://www.facebook.com/ABC   => User name/page name should have the minimum length of 5.

For the above requirement I’d made following regular expression, but it is not checking the User Name or Page Name which is the only problem. Rest is working fine:

/^(https?:\/\/)?((w{3}\.)?)facebook.com\/(([a-z\d.]{5,})?)$/

I am very new to Regular Expression, so don’t have much idea about it.

Any type of help would be appreciable.

Thanks in advance.

  • 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-14T22:49:46+00:00Added an answer on June 14, 2026 at 10:49 pm

    parse_url() can help you with that.

    <?php
    
    $array = array(
        "www.facebook.com/ABCDE",
        "facebook.com/ABCDE",
        "http://www.facebook.com/ABCDE",
        "https://www.facebook.com/ABCDE",
        "http://www.facebook.com/",
        "http://www.facebook.com/ABC"
    );
    
    foreach ($array as $link) {
        if (strpos($link, "http") === false) {
            $link = "http://" . $link; //parse_url requires a valid URL. A scheme is needed. Add if not already there.
        }
        $url = parse_url($link);
        if (!preg_match("/(www\.)?facebook\.com/", $url["host"])) {
            //Not a facebook URL
            echo "FALSE!";
        }
        elseif (strlen(trim($url["path"], "/")) < 5) {
            //Trailing path (slashes not included) is less than 5
            echo "FALSE!";
        }
        else {
            //None of the above
            echo "TRUE";
        }
        echo "<br>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to validate url, so I used site http://www.rubular.com/ and maybe I get
I need to validate a textBox entry which contains time. Time should be in
I need to validate a phone number in javascript. The requirements are: they should
I need to validate errors before it goes to action url of the form.
I need to validate an email address which will be transmitted to several possible
I need to validate a web page markup programmatically and I heard it's possible
I need validate the given input String is a valid Timestamp in milliseconds. For
I need to validate an XML string (and not a file) against a DTD
I am following the instructions on this page to create a PHP script which
I need validate some attributes ONLY if they are not empty. For example the

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.