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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:26:03+00:00 2026-06-09T02:26:03+00:00

I need a function or Regex string for PHP that I can pass a

  • 0

I need a function or Regex string for PHP that I can pass a string through like so:

Lorem ipsum dolor sit amet, http://www.gettyimages.com/images/marketing/frontdoorStill/PanoramicImagesRM/FD_image.jpg consectetur adipiscing elit. Nullam sed diam lectus, a rutrum orci. Suspendisse potenti. Nulla facilisi. Suspendisse potenti. Ut http://www.handsonuniverse.org/get_images/images/20090802.ngc6992.HOS.jpg ullamcorper mauris sit amet elit tristique sit amet laoreet nunc condimentum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam euismod arcu non odio http://www.prelovac.com/vladimir/wp-content/uploads/2008/03/example.jpg aliquam vestibulum. Sed eleifend tellus id augue luctus ac ultrices leo semper.

And I would would get in return get:

http://www.gettyimages.com/images/marketing/frontdoorStill/PanoramicImagesRM/FD_image.jpg
http://www.handsonuniverse.org/get_images/images/20090802.ngc6992.HOS.jpg
http://www.prelovac.com/vladimir/wp-content/uploads/2008/03/example.jpg

in an array. I need it to grab the URL’s based on weather or not they contain regular image extensions, such as *.jpg, *.png, *.bmp, etc. Anyone know one that exists so I can avoid reinventing the wheel? 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-06-09T02:26:04+00:00Added an answer on June 9, 2026 at 2:26 am

    Well, below will work for your example:

    preg_match_all('/(https?:\/\/\S+\.(?:jpg|png|gif))\s+/', $content, $matches);
    

    Add whatever other extensions you want to capture.

    Note that the above is not necessarily robust (it would not match www.blah.com/image.jpg for example). Nor would it match URLs that did not end in the extension, even if they were images (ie, http://domain.com/blah.jpg?loadsmall=true or something). There are ways to make it more smart, but it really depends on what sort of input you are expecting, as that would drive how complex your parsing needs to be.

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

Sidebar

Related Questions

I need a regex or a function in PHP that will validate a string
I need a function that can print Turkish characters. public String convert(String input) {
I need a PHP function that will take a string as input, and return
I need a regex that matches all instances of a particular PHP function name
I need help writing a regex function that converts HTML string to a valid
I need the regex to find function calls in strings in php, I have
I need a function that could generate a regex. For example if I write
in function need key to encrypt string without mcrypt libraly in php function encrypt($str,
I need a function that can intersect 2 arrays for example: $Array1 = array(1,2,3);
I need a regex that tests a string for a minimum of 14 characters

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.