Grr. Sitepoint threw away a relatively long answer because I had a URL in it, then I had to go out so now I am trying to remember what I wrote a few hours ago.
I’m not sure what the problem was which was causing your error report, but I have got another potential candidate regular expression for you. As for the missing $wp_query->query_vars[‘name’] I based my suggestion on your snippet from Joost de Valk’s code which did not have that bit. Is this a change you have made?
Anyway, I have been using “regex powertoy” an on-line tool at regex dot powertoy dot org to try things out and come up with the following regular expression:
\\/([0-9]+-)?([^/]*/?)(\\.(html|htm|php|asp|aspx)|([0-9]+))$
in your php this would look like
$s = preg_replace("/\\/([0-9]+-)?([^/]*/?)(\\.(html|htm|php|asp|aspx)|([0-9]+))$/","$2",$wp_query->query_vars['name']);
given
http://mysite.com/show-podcasts/49-green-patriot-radio-with-david-steinman/4804
this produces
green-patriot-radio-with-david-steinman/
which seems to be what you wanted.
To have a play for yourself, go to “regex powertoy”, click to edit the bottom panel and add your URL. Then enter the following into the top panel
s!\\/([0-9]+-)?([^/]*/?)(\\.(html|htm|php|asp|aspx)|([0-9]+))$!/$2!
Note that the S!..!$2! is the equiavalent of your call to preg_replace
You can choose “highlight matches” or “show replacements” from the drop-down menu in the middle to see the effect.
If you wanted to remove all digits and leave everything else, you might be better doing it in two passes. the first is as originally supplied, then the second eats all the digits:
$s = preg_replace("/(.*)-(html|htm|php|asp|aspx)$/","$1",$wp_query->query_vars['name']);
$s = preg_replace("/[0-9]+/","",$s);
This will potentially leave some odd dashes hanging around, if you want to convert those to spaces at the same time, you could do the following instead:
$s = preg_replace("/(.*)-(html|htm|php|asp|aspx)$/","$1",$wp_query->query_vars['name']);
$s = preg_replace(array("/[0-9]+/","/-/"),array(""," "),$s);
I hope this gives you some approaches to think about.
Frank.