Skip to content

Instantly share code, notes, and snippets.

@abhibeckert
Created March 5, 2014 00:51
Show Gist options
  • Save abhibeckert/9359024 to your computer and use it in GitHub Desktop.
Save abhibeckert/9359024 to your computer and use it in GitHub Desktop.
<?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