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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:18:26+00:00 2026-05-12T23:18:26+00:00

I have a bunch of strings, each containing an anchor tag and url. string

  • 0

I have a bunch of strings, each containing an anchor tag and url.

string ex.

here is a link <a href="http://www.google.com">http://www.google.com</a>. enjoy!

i want to parse out the anchor tags and everything in between.

result ex.

here is a link. enjoy!

the urls in the href= portion don’t always match the link text however (sometimes there are shortened urls,sometimes just descriptive text).

i’m having an extremely difficult time figuring out how to do this with either regular expressions or php functions. how can i parse an entire anchor tag/link from a string?

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-05-12T23:18:26+00:00Added an answer on May 12, 2026 at 11:18 pm

    You shouldn’t use regex to parse html and use an html parser instead.

    But if you should use regex, and your anchor tags inner contents are guaranteed to be free of html like </a>, and each string is guaranteed to contain only one anchor tag as in the example case, then – only then – you can use something like:

    Replacing /^(.+)<a.+<\/a>(.+)$/ with $1$2

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

Sidebar

Related Questions

I have an XML document with a bunch of elements, each containing a timestamp
I have a bunch of strings like memory.caching and server.base.url. Within my configuration object
I have a bunch of strings like this: 'ABCD99991000' 'XYZ79991000' 'E2493991039' What I really
On my java project, I have a bunch of strings externalized on a messages.properties
I have a JList that holds a bunch of strings . I would like
I have a bunch of string with special escape codes that I want to
I have a bunch of records with dates formatted as a string such as
I have a bunch of named value parameters in a Dictionary<string, object> , which
So, I have a string of text: string with a bunch of links but
I have a bunch of strings representing mathematical functions (which could be nested and

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.