Jump to content

[SOLVED] Regex [img] tags


chocopi

Recommended Posts

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 ;D

 

~ Chocopi

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ;D

 

~ Chocopi

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.