vordmeister - 5:30 pm on Sep 11, 2011 (gmt 0)
I've always struggled with regular expresions. Normally it's possible to pinch something from the web but I should really start understanding it. Could anyone suggest a good book or tutorial?
Just at the moment I'm trying to replace images linked using bbcode from certain sites with an error message while retaining the rest of the text in the post. Here is what I have:
$string = "Lots of text [IMG]http://example.com/image1.jpg[/IMG] and [IMG]http://example.com/image2.jpg[/IMG] more text";
$pattern = "/[\[IMG\].?example.?\[/IMG\]]/";
$replacement = "Images from example.com not allowed";
echo preg_replace($pattern, $replacement, $string);
Obviously that gives errors right now. Would much appreciate help.