Php正则表达式,匹配{}字符未显示

I'm currently working on my own template engine for educational purposes.

Now I'm stuck at this part where I want to match if the string contains the following for e.g:

$article.author

Here's my regex pattern so far: http://www.phpliveregex.com/p/fx2

Current pattern matches both {$article.author} and $article.author.

But it should only match $article.author.

Any help would be greatly appreciated, Jumpy.

You need to use anchors for finding exact match as

^\$[^|{}]*$

Regex Demo

PHP Code

$re = "/^\\$[^|{}]*$/m"; 
$str = "\$article.author
{\$article.timestamp}"; 
preg_match_all($re, $str, $matches);
print_r($matches);

Ideone Demo

Is this what you are looking for?

^\$.*

http://www.phpliveregex.com/p/fx3