eval.in

Paste #47069

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>\S*)\R.*\R^reg.no (?<regnr>\S*)/m'
    , $str, $matches
);

var_dump($result, $matches);

Program Output

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

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

Fork