Quick Regular Expression Question

Alright in the PHP site I'm building there are tags like [img]url[/img]. These will appear in big strings of text that present posts. How can I use a regular expression to strip [img]image.jpg[/img] out for example, but image.jpg can be anything! This is because I dont want tags and their attributes to appear in search results.

Thank you for your help. Code would be nice.
LVL 2
LinkyAsked:
Who is Participating?
 
ZylochConnect With a Mentor Commented:
Hi Linky,

preg_replace('/\[img\].*?\[\/img\]/', '', $text);

Regards,
Zyloch
0
 
LinkyAuthor Commented:
Thank you very much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.