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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:28:18+00:00 2026-05-10T13:28:18+00:00

I was reading this question about how to parse URLs out of web pages

  • 0

I was reading this question about how to parse URLs out of web pages and had a question about the accepted answer which offered this solution:

((mailto\:|(news|(ht|f)tp(s?))\://){1}\S+) 

The solution was offered by csmba and he credited it to regexlib.com. Whew. Credits done.

I think this is a fairly naive regular expression but it’s a fine starting point for building something better. But, my question is this:

What is the point of {1}? It means ‘exactly one of the previous grouping’, right? Isn’t that the default behavior of a grouping in a regular expression? Would the expression be changed in any way if the {1} were removed?

If I saw this from a coworker I would point out his or her error but as I write this the response is rated at a 6 and the expression on regexlib.com is rated a 4 of 5. So maybe I’m missing something?

  • 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. 2026-05-10T13:28:19+00:00Added an answer on May 10, 2026 at 1:28 pm

    @Jeff Atwood, your interpretation is a little off – the {1} means match exactly once, but has no effect on the ‘capturing’ – the capturing occurs because of the parens – the braces only specify the number of times the pattern must match the source – once, as you say.

    I agree with @Marius, even if his answer is a little terse and may come off as being flippant. Regular expressions are tough, if one’s not used to using them, and the {1} in the question isn’t quite error – in systems that support it, it does mean ‘exactly one match’. In this sense, it doesn’t really do anything.

    Unfortunately, contrary to a now-deleted post, it doesn’t keep the regexp from matching http://http://example.org, since the \S+ at the end will match one or more non-whitespace characters, including the http://example.org in http://http://example.org (verified using Python 2.5, just in case my regexp reading was off). So, the regexp given isn’t really the best. I’m not a URL expert, but probably something limiting the appearance of ‘:’s and ‘//’s after the first one would be necessary (but hardly sufficient) to ensure good URLs.

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

Sidebar

Related Questions

I was reading over this question and wondered if the accepted answer might also
This question follows this other question about C declarations . Reading the answer to
After reading this question , i saw the answer by Naveen containing a link
I was reading this question, but didn't understand some part of the aix's answer
I was reading this question (which you do not have to read because I
After reading answer to this question: Make "make" default to "make -j 8" I
After reading this question - which also provides links to documentation , I still
Really simple question about C++ constness. So I was reading this post , then
I have a few questions about this after reading the iPhone documentation on it:
I was reading about this person's interview at a well-known search company. http://asserttrue.blogspot.com/2009/05/one-of-toughest-job-interview-questions.html He

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.