fork download
  1. <?php
  2.  
  3. $re = '/(?P<first>[^#\s][^#]*)#(?P<second>\d{0,7}\.\d{1,2}|\w+)/';
  4. $str = 'Test 1#1.00 Test 2#2.00 Test 3#3.00
  5. Test 1#1.00 Test 2#FOC Test 3#3.00';
  6. preg_match_all($re, $str, $matches);
  7. print_r($matches["first"]);
  8. echo "\n";
  9. print_r($matches["second"]);
Success #stdin #stdout 0.02s 23744KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Test 1
    [1] => Test 2
    [2] => Test 3
    [3] => Test 1
    [4] => Test 2
    [5] => Test 3
)

Array
(
    [0] => 1.00
    [1] => 2.00
    [2] => 3.00
    [3] => 1.00
    [4] => FOC
    [5] => 3.00
)