0

There is page code

<a href="test.html" class="title">
            FOR IMAGE TEST        </a>
        <div class="meta">
                                            <span class="social" style="float:left;background-color:#28AF61">Facebook</span>
                        <span class="views">160</span>
            <span class="username">
                                    <a href="/profile/5282794">Razvie-arr</a>                            </span> -
            <span class="pubdate">Jan, 29, 18:23</span>
        </div>

                                    <div class="favorite" title="Add news"></div>
                        </div>
    <div class="body">
        asd <br /><br /><br /><div style="text-align:center;"><a href="//media.com/upload/photo/2021/01/29/normal/asdasa.jpeg"><img src="//media.com/upload/photo/2021/01/29/asdq.jpeg" alt="media image" /></a></div><br /><br />lefg<br /><br /><br />Link: <a href="//google.com" target="_blank">gog</a><br /><br /><br />    </div>

I need to highlight this code using regex for further replacement

<a href="//media.com/upload/photo/2021/01/29/normal/asdasa.jpeg"><img src="//media.com/upload/photo/2021/01/29/asdq.jpeg" alt="media image" /></a>

But i have condition, regex should see this line <a href="test.html" class="title">

I tried to implement it like this: <a href="(.*?) class="title">(.*?)<a href="(.*?)"><img src=(.*?)>(.*?)<\/a>

but it doesn't work, most likely due to tabs

Razvie-arr
  • 39
  • 4
  • 1
    Avoid using regex to parse HTML content. – Tim Biegeleisen Feb 08 '21 at 05:49
  • Unofficially, we aren't "allowed" to answer such questions (because of [this post](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags)). You need to use a proper HTML parser to extract the data you want. Plenty of examples online about this. – costaparas Feb 08 '21 at 05:50

0 Answers0