Solved

Quick Regular Expression Question

Posted on 2006-06-23
2
243 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
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 …

820 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