Can someone tell me how to take a string and run a function against it to check for a specific type of file (say a ".pdf"). If the string contains the file, then it needs to apply a "pdf" class to the anchor that contains the link.
Here's an example of a string:
<a href="/downloads/myfile.pdf">My PDF</a>
I would like it to be changed to this:
<a href="/downloads/myfile.pdf" class="pdf">My PDF</a>