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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:49:25+00:00 2026-06-08T16:49:25+00:00

I’ve got a weird issue with trying to match a url containing an image

  • 0

I’ve got a weird issue with trying to match a url containing an image file extension on the end. The regex im using is pretty simple (has no url validation as such but as a first iteration will do for now).

I’ve set up a fiddle which should explain it better than i can in words. See the fiddle here:

http://jsfiddle.net/Vwat2/1/

Notes:

  1. Make sure your testing in chrome
  2. Make sure you have task manager open for chrome (settings icon > tools > task manager)
  3. Run the jsfiddle, the regex without the file extension match on the end will fire 3 seconds after you copy the url into the textarea and will be ok), 3 seconds after that the one WITH the file extension match will fire, if it’s affecting you, the text will not change to fired and you will see jsfiddle eat up CPU in the task manager

Hopefully someone can explain what is going on here, i’ve run the regex in PHP and in expresso and it doesn’t have any issues so i dont think its stuck in some sort of regex internal loop or anything.

Thanks for any help

Edit: Heres a slimmed down version which more closely resembles my use of it in my application (ive removed the timers and other helpers from the first fiddle).

http://jsfiddle.net/A96Mw/1/

  • 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-08T16:49:26+00:00Added an answer on June 8, 2026 at 4:49 pm

    Seems to be a case of Catastrophic Backtracking because of this expression: (?:[^ ]+)+. Not sure why the first one works while the second doesn’t.

    The regexes you want are

    url = new RegExp("https?://(?:[^ ]+)\\.", "i")
    // or
    url = /https?:\/\/(?:[^ ]+)+\./i
    

    and

    imgurl = new RegExp("https?://(?:[^ ]+)\\.(?:jpe?g|gif|png)", "i")
    // or
    imgurl = /https?:\/\/(?:[^ ]+)+\.(?:jpe?g|gif|png)/i
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to render a haml file in a javascript response like so:
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace

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.