- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
$pattern = '/
(?x) # free-spacing modifier
^ # start of the line
[[:space:][:punct:]]* # ignore any leading trash
(?P<street>[[:alpha:][:space:]]+[[:alpha:]]) # street name (any letter from any language)
[[:space:][:punct:]]* # separator
(?P<house> # house group
[[:digit:]] # must start with the digit
[[:digit:][:alpha:][:space:][:punct:]]* # any continue with digit, letter, space or punctuation (if necessary)
)
[[:space:][:punct:]]* # ignore any trailing trash (not working)
$ # end of the line
/u';
$sample = 'Potsdamer Straße 124-126';
echo (int)preg_match( $pattern, $sample, $matches).PHP_EOL;
print_r($matches);