Solved

PREG Reg Expression to match token

Posted on 2013-01-25
2
383 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now