How can I search a url and append?

How can I search a url and append?

Hi there,

I'm really stuck and would be very grateful if someone could please help me.

I have the following code:

<a href="downloads/file/trf.pdf">TRF.pdf</a>
<a href="downloads/documents/file/trf.pdf">XYZ.pdf</a>

I need some code that can search through all a-links on a page and check for any of them that contain 'downloads/file' and then add a small icon after the 'trf.pdf' or any other pdf file that happens to be on that a-link. Any other link that doesn't have /downloads/file in its path should be disregarded.

So looking at the example I have put above, I would like only the TRF.pdf to get the icon displaying after the pdf because it has /downloads/file in the path, where the second one does not.

Many thanks!