Last active
August 29, 2015 14:16
-
-
Save jancimajek/1d39929d9212fb366b7a to your computer and use it in GitHub Desktop.
Test of preg_match replacement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
t( | |
array( | |
'www.notft.com', | |
'ft.com', | |
'.ft.com', | |
'x.ft.com.au', | |
'x.ft.com', | |
), | |
function ($t) | |
{ | |
return preg_match('/^(.+)\.ft\.com$/', $t); | |
}, | |
function ($t) | |
{ | |
return (substr($t, -7) === '.ft.com') && strlen($t) > 7; | |
} | |
); | |
function t($ta, $o, $n) | |
{ | |
foreach ($ta as $t) { | |
printf( | |
'OLD:%d -- NEW:%d -- %s' . PHP_EOL, | |
$o($t), | |
$n($t), | |
$t | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment