Page 1 of 1

PHP preg_match [ and ] alternatives

Posted: Sat Jul 28, 2007 6:25 pm
by AiRSh33p
Hello,

I am using the preg_match command in my PHP code. however in the script I need to get values inside the [ ] brackets

i have tried:

Code: Select all

\[member\](.+)\[/member\]
using the \ however this doesn't work please HELP!

Thanks!

Posted: Sat Jul 28, 2007 6:48 pm
by nathanr
need more info.. surely you can't be trying to match the word member??

'\([matchchars])T*.T([matchchars])\'

where T is the trigger, you might want to check out the pattern syntax and modifiers documentation over on php.net...

preg_match returns whatever is in () brackets..

Posted: Sat Jul 28, 2007 7:08 pm
by Ollie Saunders
Perhaps you're using / as your delimiter and this will work for you:

Code: Select all

\[member\](.+)\[\/member\]