...

View Full Version : Regular Expression



gwendaal
12-09-2004, 09:12 AM
I would like to replace any string with this format :
[any thing inside]

to remove the text inside [] + the brackets

thank you for your help

Sayonara
12-09-2004, 09:53 AM
If you simply want to remove both the square brackets and the arbitrary content they enclose (allowing for multiline and case-insensitivity), this ought to do it:



$string = $your_text_source;
$pattern = '/\[((im).+)\]/';
$replace = '';

preg_replace($pattern, $replace, $string);

gwendaal
12-09-2004, 10:37 AM
of course i am not using php but asp net
but i shall try "/\[((im).+)\]/'"

thank you



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum