Last active
August 29, 2015 14:08
-
-
Save ironsmile/533a5f6aaecb04d27b68 to your computer and use it in GitHub Desktop.
Do you spot the bug?
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 | |
$string = 'lalalalala'; | |
$string = preg_replace('/(a+)/', 'many-a', $string); | |
// continue my work with string | |
// hopefully it is "lmany-almany-almany-almany-almany-a" | |
?> |
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 | |
$string = 'lalalalala'; | |
$preg_ret = preg_replace('/(a+)/', 'many-a', $string); | |
if ($preg_ret === null) { | |
throw new Exception("Preg replace did an error: ", preg_last_error()); | |
} | |
$string = $preg_ret; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment