Question

My preg_match_all function:

preg_match_all("{lang:(.*?)}", $template, $found_langs);

The template is like:

<h1>{lang:Choose sport}</h1>

But it won't find it... BUT if I use this:

preg_match_all("{lang:(\w*)}", $template, $found_langs);

It'll find Choose. I need to find Choose sport..

Anyone knows why (.*?) won't work?

Was it helpful?

Solution

Try to escape { char and use // for RegEx pattern in preg_match_all:

preg_match_all("/\{lang:(.*?)\}/i", $template, $found_langs);

And //i at the end of pattern is a case insensitivity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top