I want ot get a match from my identifier.
I have a string like this coming in {/describe:foo}
where I am trying to
match {/describe:}
to return foo
, but am not getting the regex right, would
someone mind pointing out what I did wrong? here's my match.
$regexp = '/\{describe:(.*?)\}/i';
$query = '{/describe:foo}';
preg_match($regexp, $query, $match);
print_r($match); // (bool) false
Background I hope this can help others, a good reason to do this is to create replaceable control words in a string that can be interpreted and replaced, here's an example of a RESTful poster that will run a descriptor on a control word.
if (preg_match('/\{describe:(.*?)\}/i', $_POST['query'], $match))
{
// Describe Salesforce Object from internal POST tool
print_r($SforceConnection->describeSObjects($match[1]));
exit;
}
You are missing the forward slash in your regexp:
$regexp = '/\{\/describe:(.*?)\}/i';
or:
$regexp = '#\{/describe:(.*?)\}#i';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With