Link to home
Start Free TrialLog in
Avatar of richardsimnett
richardsimnett

asked on

PREG Reg Expression to match token

Hello,
Im trying to write a PREG (php) based reg expression to replace any tokens embedded within a template to "". Unfortunately, I cant seem to figure out how to properly match the tokens.

The tokens are formatted as follows:

[@ operator @]

I need to be able to replace [@ * @] with just nothing.

I have tried /[\[@] + [@\]]/, and various variations with no luck. I suspect my problem is that Im unsure as how to force the literal on the [ ], as well as unsure how to match anything in the middle.

Thanks,
Rick
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of richardsimnett
richardsimnett

ASKER

Excellent. I didnt catch that I had to escape both the [ and the @. Thank you!