Created
March 5, 2014 00:51
-
-
Save abhibeckert/9359024 to your computer and use it in GitHub Desktop.
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 | |
$substitution = '5tv0WiPg2YoSNCRzzBUZc7Bozp2WhLmODSMmc8qlTNh8MdUJVyPx9lj3vngJzFn'; | |
$regexPattern = str_replace('*', $substitution, $customRulePattern); // replace "*" with random substitution, to avoid being preg_quote() escaped | |
$regexPattern = preg_quote($regexPattern); // escape all regex syntax | |
$regexPattern = str_replace('/', '\/', $regexPattern); // also escape the "/" character, since we are using that as the preg delimiter | |
$regexPattern = str_replace($substitution, '.*', $regexPattern); // convert $substitution into the correct regex pattern | |
$regexPattern = "/$regexPattern/s"; // wrap in / and add the "DOTALL" flag | |
return (preg_match($regexPattern, $answerStr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment