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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:58:52+00:00 2026-05-10T21:58:52+00:00

I have the following regex expression to match html links: <a\s*href=[‘|](http:\/\/(.*?)\S[‘|]> it kind of

  • 0

I have the following regex expression to match html links:

<a\s*href=['|'](http:\/\/(.*?)\S['|']> 

it kind of works. Except not really. Because it grabs everything after the < a href… and just keeps going. I want to exclude the quote characters from that last \S match. Is there any way of doing that?

EDIT: This would make it grab only up to the quotes instead of everything after the < a href btw

  • 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-10T21:58:52+00:00Added an answer on May 10, 2026 at 9:58 pm

    I don’t think your regex is doing what you want.

    <a\s*href=['|'](http:\/\/(.*?)\S['|']> 

    This captures anything non-greedily from http:// up to the first non-space character before a quote, single quote, or pipe. For that matter, I’m not sure how it parses, as it doesn’t seem to have enough close parens.

    If you are trying to capture the href, you might try something like this:

    <a .*?+href=[''](http:\/\/.*?)[''].*?> 

    This uses the .*? (non-greedy match anything) to allow for other attributes (target, title, etc.). It matches an href that begins and ends with either a single or double quote (it does not distinguish, and allows the href to open with one and close with the other).

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

Sidebar

Related Questions

I have written the following regex to match a set of e-mails from HTML
I have Googled it, and found the following results: http://icfun.blogspot.com/2008/03/regular-expression-to-handle-negative.html http://regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3 With some (very
I have the following text Ad:<font class=value>1234 Blues </font> Regex expression value>([^<]+) will match
I have the following Regex to match all link tags on a page generated
I have the following regex that isn't working. I want to match the string
Possible Duplicate: RegEx match open tags except XHTML self-contained tags I have this list
I have the following Regex used to match PHP Class, method and Function names
I have the following regex which suppose to match email addresses: [a-z0-9!#$%&'*+\\-/=?^_`{|}~][a-z0-9!#$%&'*+\\-/=?^_`{|}~.]{0,63}@[a-z0-9][a-z0-9\\-]*[a-z0-9](\\.[a-z0-9][a-z0-9\\-]*[a-z0-9])+$. I have
I've been given the following regex expression: if (preg_match_all('(http://)?(www[.])?(youtube|vimeo)[^\s]+'is,$prova,$n)) { foreach ($n[3] as $key
I'm using the following regular expression <a href=[^/] to find all links which do

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.