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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:11:34+00:00 2026-05-30T17:11:34+00:00

can you please tell me how to validate a hyperlink from different hyperlinks. eg

  • 0

can you please tell me how to validate a hyperlink from different hyperlinks. eg

i want to fetch these links separately starting with the bolded address(between two stars) from a website using simple html dom

1 http://**www.website1.com**/1/2/
2 http://**news.website2.com**/s/d
3 http://**website3.com/news**/gds

i know we can do it using preg_match ;but i am getting a hardtime understanding preg_match.
can anyone give me a preg_match script for these websites validation..
and can you also explain me what this means

preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url)

what are those random looking characters in preg_match? what is the meaning of these characters?

  • 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-30T17:11:36+00:00Added an answer on May 30, 2026 at 5:11 pm

    If you want to learn about regular expression, I think you could get a good start on the regular-expressions.info website.

    And if you want to use them more, the book Mastering Regular Expressions is a must read.

    Edit: here is a simple walkthrough tho:

    • the first parameter of preg_match is the regexp string. The second is the string you’re testing against. A third optionnal one can be used and would be an array inside which everything captured is stored.
    • the | are used to delimit your regexp and its options. What is between the first one is the regexp, the i at the end is an option (meaning your regexp is case insensitive)
    • the first ^ is marking where your string you want to match starts
    • then (s)? mean that you want one or no s character, and you want to “capture it”
    • [a-z0-9]+ is any number (even 0) of alphanumeric characters
    • (.[a-z0-9-]+)* is wrong. It should be (\.[a-z0-9-]+)* to capture any number of sequences formed by a dot then at least one alphanumeric character
    • (:[0-9]+)? will capture one or no sequence formed by : followed by any number. It’s used to get the url port
    • (/.*)? captures the end of the url, a slash followed by any number of any character
    • $ is the end of your string
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi can you please tell how can i validate the multiple checkbox any one
can you please tell me how can i run a program from Adobe air
Tell me please, how can I create xsd schema, which successfully validate the following
Can you please tell me how much is (-2) % 5 ? According to
Can anyone please tell me if Certifying Authorities (CAs) are allowed to make modifications
Can anyone please tell what is change request management tool and what is involved
Can anyone please tell me why compiling a C# application with a .cs file
Can you please tell me how can I set a global #define in my
Can anyone please tell me when should I use MessageContracts and when should I
Can anybody please tell me what is the use of %NOTFOUND operator? We can

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.