3 ms·
This actually reminds me of what you get if you use named capture groups in PHP: php > $link = 'http://example.com/'; php > preg_match('#http://(?P<dom
by Zancarius 12y ago
This actually reminds me of what you get if you use named capture groups in PHP:
php > $link = 'http://example.com/';
php > preg_match('#http://(?P<domain>[^/]+)/#', $link, $matches);
php > print_r($matches);
Array
(
[0] => http://example.com/
[domain] => example.com
[1] => example.com
)
There's some utility to it, but it can provide unexpected results if you blindly iterating through the match array (though I can't see any reason to do so if you know what offsets you want).