我尝试编写正则表达式模式“\ {\ {。* \} \}”以匹配标记“{{...}}”。但它总是匹配下面的所有字符串:
{{ shortcode('') }} abc {{ shortcode('') }}
请帮助我更正模式以匹配每个标签,感谢您的帮助。
答案 0 :(得分:1)
试试这个:
$result = "SELECT T1.ID, T2.Image1, T1.unoone, T1.unotwo, T1.unothree,
T1.unofour
FROM T1 LEFT JOIN T2 ON (T1.ID=T2.Image1)
WHERE T1.ID=T2.Image1 AND T1.unoone LIKE '%".$uno_one."%'
AND T1.unotwo LIKE '%".$uno_two."%'
AND T1.unothree LIKE '%".$uno_three."%'
AND T1.unofour LIKE '%".$uno_four."%' ";
$stmt = mysqli_stmt_init($con);
$query = mysqli_stmt_prepare($stmt, $result);
if(!$query) {
die("no result");
} else {
/* execute statement */
mysqli_stmt_execute($stmt);
/* bind result variables */
mysqli_stmt_bind_result($stmt, $id, $img[0], $uno_one, $uno_two,
$uno_three, $uno_four);
/* fetch values */
while (mysqli_stmt_fetch($stmt)) {
echo $img[0];
echo $uno_one;
echo $uno_two;
echo $uno_three;
echo $uno_four;
}
/* close statement */
mysqli_stmt_close($stmt);
}
使用\{\{(.*?)\}\}
会导致匹配在第一个结束时停止。
在这里演示:
答案 1 :(得分:0)