preg_match
thermage/thermage
Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Perform a regular expression match
preg_match
(
string $pattern
,
string $subject
,
array
&
$matches
=
null
,
int $flags
=
0
,
int $offset
=
0
):
int
|
false
public function
convertRgbColorToHex
(
string $color
):
string
{
if (
preg_match
(
'/(\d{1,3})\,?\s?(\d{1,3})\,?\s?(\d{1,3})/'
,
$color
,
$matches
)) {
$color
=
sprintf
(
'%02x%02x%02x'
,
$matches
[
1
],
$matches
[
2
],
$matches
[
3
]);
}
src/Base/Color.php
private function
initDimensions
():
void
{
if (
DIRECTORY_SEPARATOR
===
'\\'
) {
if (
preg_match
(
'/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/'
,
trim
(
getenv
(
'ANSICON'
)),
$matches
)) {
self
::
$width
= (int)
$matches
[
1
];
src/Base/Terminal.php
return;
}
if (
preg_match
(
'/rows.(\d+);.columns.(\d+);/i'
,
$sttyString
,
$matches
)) {
self
::
$width
= (int)
$matches
[
2
];
self
::
$height
= (int)
$matches
[
1
];
src/Base/Terminal.php
self
::
$width
= (int)
$matches
[
2
];
self
::
$height
= (int)
$matches
[
1
];
} elseif (
preg_match
(
'/;.(\d+).rows;.(\d+).columns/i'
,
$sttyString
,
$matches
)) {
self
::
$width
= (int)
$matches
[
2
];
self
::
$height
= (int)
$matches
[
1
];
src/Base/Terminal.php
{
$info
=
$this
->
readFromProcess
(
'mode CON'
);
if (
$info
===
null
|| !
preg_match
(
'/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/'
,
$info
,
$matches
)) {
return
null
;
}
src/Base/Terminal.php