Solved

PREG Reg Expression to match token

Posted on 2013-01-25
2
398 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

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

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…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

623 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