How To Remove Anything Outside Square Brackets
Posted: Tue May 01, 2007 9:18 pm
hello
I Need A Sysntax On How To Remove what's Outside Square Brackets :
e.g if my String is
The Following Code Is Exactly The Inverse Of What I Want :
I Need A Sysntax On How To Remove what's Outside Square Brackets :
e.g if my String is
Code: Select all
$X='blablablablablabla[TEST_1]blablablablabla[TEST_2_TEST]blablab123445!$%$#^&^&$*_#$()SGJBLABLAlabla[TEST_3_ANYTHING_3]';
I Want It to Be :
' [TEST_1] [TEST_2_TEST] [TEST_3_ANYTHING_3] 'Code: Select all
preg_replace('/\[\w[^\]]*\]/s',' ',$X);