Hi Wondering whether anyone cant tell me what the diffence is between these three? Im using this in a rss feed to remove images.
The first one will match img tags with attributes before and after the src attribute. The second one will only match img tags with attributes following the src attribute. The third one will match a tags with attributes following the tag. J.D.
Keep in mind im still in a learning face. So what if my url is like this http://images.xxxx.com/f2/128/121/10841746/1097189840614_ps.gif Which of the above statements would i need to use?
This is how one of the expressions will match, provided that your URL is inside an img tag that matches the expression. (<img (.*) src=\"http:\/\/images.****.com\/(.* )>) http: / /images.xxxx.com / f2/128/121/10841746/1097189840614_ps.gif Code (markup): If the img tag doesn't match, the URL won't matter, though. For example, if your img tag uses single quotes, as shown below, the expression won't match: (<img (.*) src=\"http:\/\/images.****.com\/(.* )>) (<img src= 'http: / /images.xxxx.com / f2/128/121/10841746/1097189840614_ps.gif'>) Code (markup): J.D.
If you just want to remove images, wouldn't it be easier to do $str = preg_replace ("/<img[^>]*>/i", "", $str); PHP:
Are there any tutorials on preg replace because I found the php.net tutorial on preg replace a little limited?
It's really a regular expression tutorial you need. preg_replace has pretty simple syntax. There are a million out there and they are all pretty intimidating at first read. http://www.tote-taste.de/X-Project/regex/ http://www.mkssoftware.com/docs/man5/regexp.5.asp http://www.regexplib.com/ <-- has a testing page and a bunch of user contributed regexes - but unfortunately the testing page is .net and not php If I have some time tomorrow night, I'll throw up a php regex test page. Shouldn't take more than a few minutes, but I haven't found any online.
I spent around 2 days on a certain members problem and found the syntax pretty hard to come to terms with. Thanks for the tutorials. Hopefully it shouldn't be too confusing.
Thanks for the articles and the reply. This will give me something to read for in the weekends. I already know how to replace text.