3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $regex = '/^\s*<\S+\s*\S*>[\s\S]*?(?:^\s*<\/\S+>$)|^\s*[A-Za-z]+(?:\s+\S+)\s*$/m'; $vhost = ' DocumentRoot /www/example2 ServerName www.example.org ErrorLog /var/log/log.txt <Directory> ErrorLog /var/log/log.txt </Directory> <Directory /> ErrorLog /var/log/log.txt </Directory>'; preg_match_all($regex, $vhost, $matches); var_dump($matches);
based on 1fi9i
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(1) { [0]=> array(5) { [0]=> string(30) " DocumentRoot /www/example2" [1]=> string(29) " ServerName www.example.org" [2]=> string(30) " ErrorLog /var/log/log.txt " [3]=> string(54) " <Directory> ErrorLog /var/log/log.txt </Directory>" [4]=> string(58) " <Directory /> ErrorLog /var/log/log.txt </Directory>" } }