- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find Pattern Title
easy when you want to allow your users to post images, but in a controlled way. I used it like this (in php): $text = preg_replace("/(\[IMG\])(\S+?)(\[\/IMG\])/is", "<a href=\"\\2\" target=\"_blank\"><IMG SRC=\"\\2\" align=\"center\" height=\"100\" border=\"0\"></a>",$text); so whenever they use [img][/img] it will be converted to <a href="" target="_blank"><IMG SRC="" align="center" height="100" border="0"></a> so you get a 100 pixels high picture, and when they click on it it opens in a new window... (to prevent users from posting huge pictures and stuff)
[IMG]http://bleh.jpg[/IMG] | [ImG]bleh[/imG] | [img]ftp://login:pass@bleh.gif[/img]
<img src="bleh.jpg">
Author Rating: The rating for this expression. marnik vander elst
Source on Quakenet (
Your Rating
Bad Good

Enter New Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: I've got a question
Name: Christoph
Date: 8/5/2004 8:04:48 AM
I can't become clever. Why do you put the ? after the +. Whatfor? Greets

Title: wauw
Name: bert verbeek
Date: 2/2/2004 3:57:46 AM
wauw man, this is great, it's what i've been looking for for the past few years. You r0x0r my b0x0r!

Copyright © 2001-2018, | ASP.NET Tutorials