3v4l.org

run code in 300+ PHP versions simultaneously
<?php $extractor = function ($str) { $str = preg_replace('/\s*(?:\[at]|@)\s*/', '@', $str); $str = preg_replace('/\s*\(dot\)\s*/', '.', $str); $regexp = '/\b[a-z0-9_.-]+@(?:[a-z0-9-]+\.)+[a-z0-9]{2,4}\b/i'; preg_match_all($regexp, $str, $m); return isset($m[0]) ? $m[0] : []; }; $test_string = 'This is a test string... test1@example.org Test different formats: test2@example.org; <a href="test3@example.org">foobar</a> <test4@example.org> strange formats: test5@example.org test6[at]example.org test7@example.net.org.com test8@ example.org test9@!foo!.org test10.abc [at] hello (dot) com foobar '; print_r( $extractor($test_string) );
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.16, 8.5.0 - 8.5.1
Array ( [0] => test1@example.org [1] => test2@example.org [2] => test3@example.org [3] => test4@example.org [4] => test5@example.org [5] => test6@example.org [6] => test7@example.net.org.com [7] => test8@example.org [8] => test10.abc@hello.com )
Output for 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.

preferences:
198.57 ms | 407 KiB | 5 Q