Solved

Quick Regular Expression Question

Posted on 2006-06-23
2
216 Views
Last Modified: 2006-11-18
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.
0
Comment
Question by:Linky
2 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 50 total points
ID: 16969512
Hi Linky,

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

Regards,
Zyloch
0
 
LVL 2

Author Comment

by:Linky
ID: 16969617
Thank you very much.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now