Solved

PREG Reg Expression to match token

Posted on 2013-01-25
2
393 Views
Last Modified: 2013-01-25
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
0
Comment
Question by:richardsimnett
2 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 500 total points
ID: 38820339
And the:
\[\@.*@\]
?
0
 

Author Closing Comment

by:richardsimnett
ID: 38820398
Excellent. I didnt catch that I had to escape both the [ and the @. Thank you!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question