PHP düzenli ifade eşleşen sipariş ile sorun

0 Cevap php

Ben aşağıdaki örnek metni

The quick brown {fox} jumps over the lazy {dog}

I need to match any string enclosed in {} which can occur several times in the text.
I tried the following code but it doesn't work properly

<?php

$matches = array();

$string = "The quick brown {fox} jumps over the lazy {dog}";

preg_match("/\{(.*)\}/",$string,$matches);

print_r($matches);

?>

ve ben ne olsun

Array
(
    [0] => {fox} jumps over the lazy {dog}
    [1] => fox} jumps over the lazy {dog
)

Ben alıyorum beklediğiniz

Array
(
    [0] => {fox} jumps over the lazy {dog}
    [1] => fox
    [2] => dog
)

Peki nasıl yerine geçen bir eşleştirme "}" yakın maç için PHP zorlayabilir?

0 Cevap