I got this code from the WWW:
private function initialize_loops($template){
preg_match_all('/{LOOP:([w]+)[^}]*}((s*?.*?)*){\/LOOP:\1}/', $template, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$template = str_ireplace($match[0], '<!–LOOP('.$match[1].')–>', $template);
$this->loop_templates[strtoupper($match[1])] = $match[2];
if(!array_key_exists(strtoupper($match[1]), $this->loops)){
$this->loops[strtoupper($match[1])] = array();
}
}
return $template;
}
The Input String is: (for example)
<tbody>
{LOOP:USERLIST}
<tr>
<td>{VAR:ID}</td>
<td>{VAR:D-NAME}</td>
<td>{VAR:ROLE}</td>
<td>{VAR:ACTIONS}</td>
</tr>
{/LOOP:USERLIST}
</tbody>
I don't know for what reasons they created that RegEx in the code, becouse ist not working!
I Tried to get it workin on ReExr.com, so far I have:
/{LOOP:([^}]+)}((s*?.*?)*){\/LOOP:\1}/img
Thats still not working {LOOP:([^}]+)}{\/LOOP:\1}
already works for {LOOP:USERLIST}{/LOOP:USERLIST}
.
So my Problem is the middle Part: ((s*?.*?)*)
I absoluty cann't see why where is a s in the Expression or how it should work. Hope somebody has a Suggestion how to do it? Or an Explanation of ((s*?.*?)*)
?