chocopi Posted August 18, 2007 Share Posted August 18, 2007 I was just flicking through the tutorials on phpfreaks and came across Akitchen's phpBB tut. The pattern he uses for the img tags is: "|\[img\](http://.*?)\[/img\]|s" However, anything that starts with http:// and is within img tags will statisfy the pattern So basically the whole point of this message is can someone help me so that this pattern will only be true if it ends in an image extension. I have got a feeling this means i will have to change most of the pattern Anyways, Many Thanks ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/65580-solved-regex-img-tags/ Share on other sites More sharing options...
MadTechie Posted August 18, 2007 Share Posted August 18, 2007 try this "|\[img\](http://.*?(jpg|bmp|gif|jpeg))\[/img\]|s" PS wrong section should be in RegEx Quote Link to comment https://forums.phpfreaks.com/topic/65580-solved-regex-img-tags/#findComment-327426 Share on other sites More sharing options...
chocopi Posted August 18, 2007 Author Share Posted August 18, 2007 no that doesnt work btw im using this string: "hello your image is [img=http://www.google.com/image.gif] some extra text" And yea I know it should be in regex but they are just quite a bit slower at responses, and seeing as it is not major regex didn't think it would be too bad posting it here. ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/65580-solved-regex-img-tags/#findComment-327431 Share on other sites More sharing options...
MadTechie Posted August 18, 2007 Share Posted August 18, 2007 try this "%\[img\](http://.*?(jpg|bmp|gif|jpeg))\[/img\]%s" EDIT opps forgot the s Quote Link to comment https://forums.phpfreaks.com/topic/65580-solved-regex-img-tags/#findComment-327432 Share on other sites More sharing options...
chocopi Posted August 18, 2007 Author Share Posted August 18, 2007 Cheers, thats sorted it ! Just out of intrest do you know any good regex tutorials ? As I currently have the php pattern syntax and some other google ones, but I don't think they are that useful to me. Anyway, Thanks ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/65580-solved-regex-img-tags/#findComment-327435 Share on other sites More sharing options...
MadTechie Posted August 18, 2007 Share Posted August 18, 2007 to be truful its pratice, pratice, pratice hence i jump on these questions, i have a book "O'REILLY ~ Mastering Regular Expressions, 3rd Edition" 3rd edition has a few pages on PHP i have read about 1/3 but have be playing Regular Expressions alot i'll resume reading it soon google "Regular Expression Cheat Sheet" may help Quote Link to comment https://forums.phpfreaks.com/topic/65580-solved-regex-img-tags/#findComment-327438 Share on other sites More sharing options...
chocopi Posted August 18, 2007 Author Share Posted August 18, 2007 Cheers MadTechie, I will check it out and keep on practising I guess thats then Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/65580-solved-regex-img-tags/#findComment-327441 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.