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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:33:21+00:00 2026-06-16T01:33:21+00:00

I need to extract the information from ‘< a href=…>something.jpg< /a>’ tags from a

  • 0

I need to extract the information from ‘< a href=”…”>something.jpg< /a>’ tags from a large string recursively that could contain multiple instances of the tags. I need to do this using regex on Oracle 11g.

An example of what I am looking for is:

Example String:

The string will always contain at least 1 instance of the < a> tag and there is no maximum to how many it can contain
The href will always a xid-[[:digit:]]
The attributes in the tag can vary

<p>text about something important</p><p><a href="@X@EmbeddedFile.requestUrlStub@X@bbcswebdav/xid-1234_1" target="_blank">file.pdf</a> </p><p><a href="@X@EmbeddedFile.requestUrlStub@X@bbcswebdav/xid-1235_1" target="_blank">anotherfile.pptx</a> </p><p><a href="@X@EmbeddedFile.requestUrlStub@X@bbcswebdav/xid-1236_1" target="_blank">yetanotherfile.pdf</a> </p>

Now with that string I want to extract the 3 < a …>…< /a> blocks using

REGEXP_SUBSTR(< string>, ‘< pattern>’, < start>, < occurrence >) and adjusting the occurrence value to grab the 3 instances.

What I have so far is:

SELECT REGEXP_SUBSTR(main_data, ''<a[[:print:]]+href="[[:print:]]+xid-1234_1"[[:print:]]+>[[:print:]]+</a>'', 1, 1)
      FROM table

and the results I get from that are

<a href="@X@EmbeddedFile.requestUrlStub@X@bbcswebdav/xid-1234_1" target="_blank">file.pdf</a> </p><p><a href="@X@EmbeddedFile.requestUrlStub@X@bbcswebdav/xid-1235_1" target="_blank">anotherfile.pptx</a> </p><p><a href="@X@EmbeddedFile.requestUrlStub@X@bbcswebdav/xid-1236_1" target="_blank">yetanotherfile.pdf</a>

So it is starting with the first < a and then grabbing all the way to the last < /a>. When I need it to stop at the first instance of < /a>. Then when I increment the occurrence to 2 it should grab the second set of < a>< /a> tags. However currently setting the occurrence to 2 nothing is returned.

Any help will be appreciated. Thank you

  • 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-16T01:33:22+00:00Added an answer on June 16, 2026 at 1:33 am

    Yes, the non-greedy operator ? is the solution:

    SELECT REGEXP_SUBSTR(x,'<a href="(.*?)".*?>(.*?)</a>',1, 3, 'i', 0)
      FROM (SELECT '<p>text about something important</p><p><a href="@X@EmbeddedFile.requestUrlStub@X@bbcswebdav/xid-1234_1" target="_blank">file.pdf</a> </p><p><a href="@X@EmbeddedFile.requestUrlStub@X@bbcswebdav/xid-1235_1" target="_blank">anotherfile.pptx</a> </p><p><a href="@X@EmbeddedFile.requestUrlStub@X@bbcswebdav/xid-1236_1" target="_blank">yetanotherfile.pdf</a> </p>' as x FROM DUAL);
    

    returns

    <a href="@X@EmbeddedFile.requestUrlStub@X@bbcswebdav/xid-1236_1" target="_blank">yetanotherfile.pdf</a>
    

    or the other tags if you change the 3 to 1 or 2.

    If you replace the last 0 with 1, you get the contents of the href:

    @X@EmbeddedFile.requestUrlStub@X@bbcswebdav/xid-1236_1
    

    If you replace it with 2, you get

    yetanotherfile.pdf
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to extract the following pieces of information from any jpg that is
I have a string input from which I need to extract simple information, here
I need to extract information from an LDAP connection string like this one: ldap://uid=adminuser,dc=example,c=com:secret@ldap.example.com/dc=basePath,dc=example,c=com
I need to extract two seperate information from a string. For example, $string =
In my work we need to generate contract documents that dynamically extract information from
I want to extract information from a large website and generate an ontology. Something
I need to be able to split a string that contains email's From information.
I have a 1.3GB text file that I need to extract some information from
I need to parse/extract information from an html page. Basically what I'm doing is
I need to extract information from an unstructured web page in Android. The information

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.