How to write PCRE regex pattern in Amazon s3 SDK for PHP in get_object_list method
I am using Amazon S3 SDK for PHP and am trying to write a regex to find a subdirectory in a dynamic path. I understand that Amazon S3 does not have "subdirectories" like a typical filesystem, but from my understanding, the get_object_list method allows the pcre parameter to be used to search for a string in facility at S3. Using the pcre option, I am hoping to find a subdirectory in the path.
For example.
$find_directory = "foo";
$reg_ex = "/([a-zA-Z0-9_]*)/";
$response = $s3->get_object_list(MY_BUCKET, array(
'pcre' => some/path/" . $reg_ex . "/" . $find_directory . "/",
'max-keys' => 1
));
if ( (count($response)) > 0){echo "yes it exists";}else{echo "no it does not exist";}
I would expect it to find any directory path that has:
some/path/(any directory with letters, numbers, or underscores)/foo
But this regex doesn't work or the way the pcre file is formatted is wrong.
I am getting a warning:
preg_match () [function.preg-match]: separator must not be alphanumeric or backslash in sdk-1.5.2 / utilities / array.class.php on line 114
What's the correct way to write this regex inside pcre?
source to share