I have a template string that contains a set of tags that follow this schema:
$template = '
[[begin_Credit_payment]]
text1
[[end_Credit_payment]]
[[begin_COD_payment]]
text2
[[end_COD_payment]] ';
if ( preg_matchl("/[{2}begin(.+)payment]{2}(.+)[{2}end(\$1)payment]{2}/" , $template ) ) {
echo "OK";
}
I assume the problem is with my $1, as I have not used PHP's pattern matching that much (used to Perl). The only requirement for the matching is that the middle word (Credit or COD) is the same in both the begin and end tags.
Can someone help me fix my pattern?