PHP preg_match [ and ] alternatives

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AiRSh33p
Forum Newbie
Posts: 2
Joined: Thu Jul 26, 2007 6:40 pm

PHP preg_match [ and ] alternatives

Post 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!
User avatar
nathanr
Forum Contributor
Posts: 200
Joined: Wed Jun 07, 2006 5:46 pm

Post 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..
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Perhaps you're using / as your delimiter and this will work for you:

Code: Select all

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