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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:52:43+00:00 2026-06-10T02:52:43+00:00

strange problem here that I’ve been pondering. I have a string that contains HTML,

  • 0

strange problem here that I’ve been pondering. I have a string that contains HTML, possibly with hyperlinks in it. Consider the text below:

Hello this is my EXAMPLE string of html here's a <tag> and here's another </tag>. Blah blah I'm going to hyperlink some stuff with <a href="http://www.example.com/> anchor text </a> and then finish my sentence.

As you can see above, the phrase anchor text is the anchor text for a hyperlink to example.com.

I want to be able to search for a substring like anchor or example and determine whether or not each occurrence is part of a hyperlink, whether it be anchor text, the url, or the a tag.

Preferably, there would be an array returned with a true/false for each occurrence of the search term. Case-insensitive search would be good, and it would be nice if it returned the matching occurrence, so we’d know the case and such. An ideal response for the above example would be something like this:

$array[0][0] = "EXAMPLE"
$array[0][1] = false
$array[1][0] = "example"
$array[1][1] = true

The index of each occurrence might also be useful information to return. 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-06-10T02:52:44+00:00Added an answer on June 10, 2026 at 2:52 am

    You need to check all three cases, I think.

      #<a[^>]*>[^<>]*YOURTEXT[^<>]*</a>#
    

    covers the first case,

      #<a[^>][^<>]*YOURTEXT[^<>]*>[^<>]*</a>#
    

    would cover the second and third cases.

    Or maybe you’d better check with a more tolerant regexp,

      #<a[^<>]*>*[^<>]*YOURTEXT[^<>]*>*[^<>]*</a>#
    

    and then verify with a HTML parser if the found text is indeed a valid A tag. The first test would ensure you that your text is in the captured snippet, and the second that the snippet is indeed a hyperlink.

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

Sidebar

Related Questions

I've got a strange problem here. I have a class that I'll call MainView
This is a pretty strange problem. I have a book that I have been
Very strange problem with my iPhone App. We have an App that has been
I've got a strange problem here. Assume that I have a class with some
I'm having a strange problem here... I have an ASP.NET 3.5 application that has
I have a strange problem with mod_rewrite, the rules that are relevant here are:
I'm having a really strange problem. Here is the code I have that should
I have a feeling my problem is a bit strange, but here goes... I
I've got a strange problem here. I have a winforms panel which programatically has
I have a strange problem that the plot overlaps in the graph, but not

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.