I have created a custom tag that needs to be stripped out and replaced before a page gets rendered. The tag looks like this: [@ customTagToBeReplaced]
The preg_replace pattern I am using is like this in php:
$pattern = "/\[@ .*\]/is";
When I have implemented it, sometimes more or less characters are stripped leaving half of an html tag broken. Like this:
before:
<div class="">
[@ error]
</div>
after:
<div class="</div>
Your pattern is too greedy, try with something more specific:
\wMatches any word character (alphanumeric & underscore).