How to add a class to a hyperlink when it contains a specific file extension?

Latdeafepal

New Member
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:\[code\]<a href="http://stackoverflow.com/downloads/myfile.pdf">My PDF</a>\[/code\]I would like it to be changed to this:\[code\]<a href="http://stackoverflow.com/downloads/myfile.pdf" class="pdf">My PDF</a>\[/code\]
 
Top