eval.in

Paste #47062

PHP — PHP 5.4.6, pasted 7 months ago

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<?php

$str = "Iban: EU4320000713864374\r\nSwift: DTEADCCC\r\nreg.no 2361 \r\naccount no. 1234531735";

$result = preg_match(
    '/^Iban: (?<iban>.*)\R.*\R^reg.no (?<regnr>.*)/m'
    , $str, $matches
);

var_dump($result, $matches);

Program Output

int(1)
array(5) {
  [0]=>
  string(56) "Iban: EU4320000713864374
Swift: DTEADCCC
reg.no 2361 
"
  ["iban"]=>
  string(19) "EU4320000713864374
"
  [1]=>
  string(19) "EU4320000713864374
"
  ["regnr"]=>
  string(6) "2361 
"
  [2]=>
  string(6) "2361 
"
}

OK (0.008 sec real, 0.010 sec wall, 13 MB, 73 syscalls)

Fork