Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Perform a regular expression match
<?php preg_match( string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int|false
<?php private static function downloadVendorArchive(string $s3String, string $downloadPath): void
{
preg_match('~s3\:\/\/([^\/]+)\/(.*)~', $s3String, $matches);
$bucket = $matches[1];
$filePath = '/' . $matches[2];
$region = getenv('AWS_REGION');
<?php private static function downloadVendorArchive(string $s3String, string $downloadPath): void
{
preg_match('~s3\:\/\/([^\/]+)\/(.*)~', $s3String, $matches);
$bucket = $matches[1];
$filePath = '/' . $matches[2];
$region = getenv('AWS_REGION');
<?php private static function downloadVendorArchive(string $s3String, string $downloadPath): void
{
preg_match('~s3\:\/\/([^\/]+)\/(.*)~', $s3String, $matches);
$bucket = $matches[1];
$filePath = '/' . $matches[2];
$region = getenv('AWS_REGION');
<?php function assertMatchesRegex(string $expected, string $actual)
{
if (preg_match($expected, $actual) === false) {
throw new Exception("$actual does not match regex $expected");
}
}
<?php $serverlessInfoOutput = $serverlessInfo->getOutput();
$region = [];
preg_match('/region: ([a-z0-9-]*)/', $serverlessInfoOutput, $region);
$region = $region[1];
$stack = [];
<?php $region = $region[1];
$stack = [];
preg_match('/stack: ([a-zA-Z0-9-]*)/', $serverlessInfoOutput, $stack);
$stack = $stack[1];
$io->writeln("Stack: <fg=yellow>$stack ($region)</>");
<?php $contextBuilder = new ContextBuilder;
curl_setopt($this->curlHandleNext, CURLOPT_HEADERFUNCTION, function ($ch, $header) use ($contextBuilder) {
if (! preg_match('/:\s*/', $header)) {
return strlen($header);
}
[$name, $value] = preg_split('/:\s*/', $header, 2);
<?php } else {
$result = null;
preg_match('/REPORT RequestId: [^\n]*(.*)/s', $stderr, $matches);
$error = trim($matches[1] ?? '');
if ($error !== '') {
$result = json_decode($error, true, 512, JSON_THROW_ON_ERROR);
<?php }
$return = preg_match('/START RequestId: .*REPORT RequestId: [^\n]*/s', $stderr, $matches);
$logs = $return ? $matches[0] : $stderr;
return [$result, $logs];