Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Searching all nested url tags and its inner value

I have some input data like:

<li style="-moz-float-edge: content-box">Test text <a href="/wiki/wiki_url" title="title1">title url</a> <i>(pictured)</i> is <b><a href="/wiki/wiki_url_charges" title="Title2 charges">Title url Charges</a></b> test data.</li>

<li style="-moz-float-edge: content-box">Test text <a href="/wiki/wiki_url" title="title1"><h1><b>title url</b></h1></a> <i>(pictured)</i> is <b><a href="/wiki/wiki_url_charges" title="Title2 charges"><img alt="About this image" src="//imgs.wikimedia.org/static-image/desc20.png" style="border: none;" /></a></b> test data.</li>

I need to filter URL-tags and innter HTML Value. That means need all data within <a href to </a> tag using regular expressions (doesn’t matter whatever it contains within the URL tag).

So, the expected output as follows:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Output of first input:

<a href="/wiki/wiki_url" title="title1">title url</a>
<a href="/wiki/wiki_url_charges" title="Title2 charges">Title url Charges</a>

Output of second input:

<a href="/wiki/wiki_url" title="title1"><h1><b>title url</b></h1></a>
<a href="/wiki/wiki_url_charges" title="Title2 charges"><img alt="About this image" src="//imgs.wikimedia.org/static-image/desc20.png" style="border: none;" /></a>

Can anyone help me how to resolve this issue using Regular Expression?

>Solution :

You can use this regex:

<a[^>]*>(.|\n\t\r)*?<\/a>

This regex will return all of a tags with or without enter.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading