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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:32:53+00:00 2026-06-10T09:32:53+00:00

Possible Duplicate: What is a good regular expression to match a URL? I have

  • 0

Possible Duplicate:
What is a good regular expression to match a URL?

I have a string sent from the server that looks like this:

“Hey, have a look at this picture here http://example.com/fantastic.jpg, isn’t it nice?”

I would like a regex function which does something like this:

function returnUrl(text) {
    regex here ...
    return url;
}

I am really bad with regex, so I am coming here asking for help. Please have a look at the picture below to get the idea of what I mean:

stackOverflow automatic url recognize

This is stackOverflow automatically changing my inserted text in a clickable URL, I suppose it’s jQuery / regex.

Thanks in advance.


EDIT:

Forgot to mention, this regex should only work for images (jpg, png, etc.) not for all links.

  • 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-10T09:32:55+00:00Added an answer on June 10, 2026 at 9:32 am

    A simple one will be :

    https?://[\w-\.\?\#\/]+
    

    A complete one (which I use) will be :

    [-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?
    

    And the last oe precisely come from What is a good regular expression to match a URL?

    EDIT

    A simple one for direct image links (see here)

    https?://[\w-\.\/]+(\.jpg|\.jpeg|\.png|\.bmp)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: php regular expression help? hi, i want to replace i like apple
Possible Duplicate: Regular expression where part of string must be number between 0-100 I'd
Possible Duplicate: Is there a good way to have a Map<String, ?> get and
Possible Duplicate: Good Primer for Python Slice Notation I have a string and I'm
Possible Duplicate: Good Primer for Python Slice Notation reverse a string in Python I've
Possible Duplicate: Is this a good way to generate a string of random characters?
Possible Duplicate: Useful Regular Expression Tutorial Hello, I recently started coding in javascript. I
Possible Duplicate: Good STL-like library for C Are there any open source C libraries
Possible Duplicate: What is a good way to get a list of files from
Possible Duplicate: What are views good for? hi, i have a doubt what 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.