- This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hi,
I’m developing a wordpress theme, and I want to extract all the HTML Links (hrefs) with the extension of MP3 into my side bar. I know the wordpress functions to get posts, etc. What I want to know is how to use PHP regular expressions to get a link for an .mp3 that exist as a link from a string variable.
For example suppose the string is,
Hello this is a WP post. Here is a link to mp3
“;
I want to be able to have a function which returns "somefile.mp3" However, I want only the links with a particular extenstion (e.g. .mp3) to be returned and not merely all the href links.
I’m a bit of a noob when it comes to PHP regular expressions, Any help would be much appreciated.
Thanks,
Deane.
The regular expression should be something like:
Try experimenting with the regex to get what you want (this would be a very helpful tool).
Have a look at http://blog.themeforest.net/screencasts/a-crash-course-in-regular-expressions/ screen cast or the series http://blog.themeforest.net/screencasts/regular-expressions-for-dummies/ from the Theme Forest blog for great tutorials on Regular expressions.
Matt