fork download
  1. <?php
  2. $re = "/(\\$[a-z]{1})(.*?)(?=\\$|$)/";
  3. $str = "10\$athis is text a\$bthis is text b/\$cthis is text\$dthis is text d";
  4.  
  5. preg_match_all($re, $str, $matches);
  6. print_r($matches);
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => $athis is text a
            [1] => $bthis is text b/
            [2] => $cthis is text
            [3] => $dthis is text d
        )

    [1] => Array
        (
            [0] => $a
            [1] => $b
            [2] => $c
            [3] => $d
        )

    [2] => Array
        (
            [0] => this is text a
            [1] => this is text b/
            [2] => this is text
            [3] => this is text d
        )

)