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 if (\preg_match('`[a-z0-9\\\\ ]`i', $regexFirstChar) === 1) {
return '';
}
<?php $arrTestVersions[$testVersion] = $default;
if (\preg_match('`^\d+\.\d+$`', $testVersion)) {
$arrTestVersions[$testVersion] = [$testVersion, $testVersion];
return $arrTestVersions[$testVersion];
}
<?php return $arrTestVersions[$testVersion];
}
if (\preg_match('`^(\d+\.\d+)?\s*-\s*(\d+\.\d+)?$`', $testVersion, $matches)) {
if (empty($matches[1]) === false || empty($matches[2]) === false) {
<?php $regexInt = '`^\s*[0-9]+`';
$regexFloat = '`^\s*(?:[+-]?(?:(?:(?P<LNUM>[0-9]+)|(?P<DNUM>([0-9]*\.(?P>LNUM)|(?P>LNUM)\.[0-9]*)))[eE][+-]?(?P>LNUM))|(?P>DNUM))`';
$intString = \preg_match($regexInt, $content, $intMatch);
$floatString = \preg_match($regexFloat, $content, $floatMatch);
<?php $regexFloat = '`^\s*(?:[+-]?(?:(?:(?P<LNUM>[0-9]+)|(?P<DNUM>([0-9]*\.(?P>LNUM)|(?P>LNUM)\.[0-9]*)))[eE][+-]?(?P>LNUM))|(?P>DNUM))`';
$intString = \preg_match($regexInt, $content, $intMatch);
$floatString = \preg_match($regexFloat, $content, $floatMatch);
if ($allowFloats === false) {
<?php if ($intString === 1 && \trim($intMatch[0]) === '0'
&& \preg_match('`^\s*(0x[A-Fa-f0-9]+)`', $stringContent, $hexNumberString) === 1
&& $this->supportsBelow('5.6') === true
) {
<?php return;
}
if (\preg_match('|^__[^_]|', $functionName) !== 1) {
return;
}
<?php ];
foreach ($itemArray as $version => $required) {
if (\preg_match('`^\d\.\d(\.\d{1,2})?$`', $version) !== 1) {
continue;
}
<?php ];
foreach ($itemArray as $version => $required) {
if (\preg_match('`^\d\.\d(\.\d{1,2})?$`', $version) !== 1) {
continue;
}
<?php }
elseif ($openTag['code'] === \T_INLINE_HTML
&& \preg_match('`(<script (?:[^>]+)?language=[\'"]?php[\'"]?(?:[^>]+)?>)`i', $content, $match) === 1
) {
$found = $match[1];
$data = [
<?php }
if ($next['code'] === \T_STRING
&& \preg_match(Numbers::REGEX_NUMLIT_STRING, $next['content'])
) {
return true;
}
<?php private function isInvalidOctalInteger($tokenContent)
{
return (\preg_match('`^0[0-7]*[8-9]+[0-9]*$`D', $tokenContent) === 1);
}
}
<?php return;
}
if ((\preg_match('`PHP_OUTPUT_HANDLER_(CLEANABLE|FLUSHABLE|REMOVABLE|STDFLAGS)`', $targetParam['clean']) === 1
|| $this->isNumber($phpcsFile, $targetParam['start'], $targetParam['end'], true) !== false)
&& $this->supportsBelow('5.3') === true
) {
<?php || $tokens[$firstNonEmpty]['code'] === \T_OPEN_SHORT_ARRAY
) {
$hasInputCharset = \preg_match('`([\'"])input-charset\1\s*=>`', $targetParam['clean']);
$hasOutputCharset = \preg_match('`([\'"])output-charset\1\s*=>`', $targetParam['clean']);
if ($hasInputCharset === 1 && $hasOutputCharset === 1) {
<?php ) {
$hasInputCharset = \preg_match('`([\'"])input-charset\1\s*=>`', $targetParam['clean']);
$hasOutputCharset = \preg_match('`([\'"])output-charset\1\s*=>`', $targetParam['clean']);
if ($hasInputCharset === 1 && $hasOutputCharset === 1) {
return;