Emanuel Schiendorfer Emanuel Schiendorfer - 1 year ago 444
Smarty Question

Counting preg_match in smarty

How to count preg_match matches in smarty? Why is the following not working?

{preg_match("/\[PGN.*](.*)\[\/PGN.*\]/", $code, $match)}


Answer Source

As far as I understand your needs, the following does work, just make the regex not greedy:

preg_match_all("~\[PGN\d+](.+?)\[/PGN\d+]~", $code, $match)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download