Comments on my site are in BBCode (example: [b]text[/b]), which is converted to HTML.
The preg_replace I use for images needs adjusting.
Currently it changes [img][login to view URL][/img] to <img src="[login to view URL]" /> .
I need the preg_replace to check the image BBCode has a valid image file type (.jpg, .png, .gif, .jpeg).
Here is the current PHP code: [login to view URL]
Hi!
So just the valid images (files with the extensions you've enumerated) must be touched by that replace. OK.
Your regexp is pretty complicated. Still, it can be worked on it. But: would you also like a clearer version of it? If so, just tell me what restrictions related to these image files YOU want to be imposed.
For instance this: (?:\s|\;|\)|\]|\[|\{|\}|,|\"|'|\<|$|\.\s) can be written in a more clearer way. But it that part needed? So what exactly you want to check the regexp? (not only the extension)
Thanks,
Anca
We will have to divide code into two parts. First part extracts file type and compares it to valid options, and second part that does what your current code does.
S.
Hi, I am a recent graduate with a degree in Computer Science.
You'd just like the regex augmented to only replace img tags that contain a valid image type?
I can have this for you tomorrow afternoon.
If you have any further questions please don't hesitate to contact me,
Tally
Brother,
I am currently working on phpBB. I am experienced on BBcode, smilies, posting etc. To see my projects please see my profile.
Before this code you use, I have to write a program that will extract the file extension. It is very simple. The string after last dot is extension. Then if else check for known file type. It is very easy to me. I can do this within 1 day. You can award me. Also before awarding you can PM me for more details.
Thank you brother...........