Documentation

Preg
in package

Table of Contents

Methods

grep()  : array<string|int, T>
isMatch()  : bool
Variant of match() which returns a bool instead of int
isMatchAll()  : bool
Variant of matchAll() which returns a bool instead of int
isMatchAllStrictGroups()  : bool
Variant of `isMatchAll()` which outputs non-null matches (or throws)
isMatchAllWithOffsets()  : bool
Variant of matchAllWithOffsets() which returns a bool instead of int
isMatchStrictGroups()  : bool
Variant of `isMatch()` which outputs non-null matches (or throws)
isMatchWithOffsets()  : bool
Variant of matchWithOffsets() which returns a bool instead of int
match()  : 0|1
matchAll()  : 0|positive-int
matchAllStrictGroups()  : 0|positive-int
Variant of `match()` which outputs non-null matches (or throws)
matchAllWithOffsets()  : 0|positive-int
Runs preg_match_all with PREG_OFFSET_CAPTURE
matchStrictGroups()  : 0|1
Variant of `match()` which outputs non-null matches (or throws)
matchWithOffsets()  : 0|1
Runs preg_match with PREG_OFFSET_CAPTURE
replace()  : string
replaceCallback()  : string
replaceCallbackArray()  : string
replaceCallbackStrictGroups()  : string
Variant of `replaceCallback()` which outputs non-null matches (or throws)
split()  : array<int, string>
splitWithOffsets()  : array<int, array{: string, : int}>
checkOffsetCapture()  : void
checkSetOrder()  : void
enforceNonNullMatchAll()  : array<int|string, array<int, string>>
enforceNonNullMatches()  : array<int|string, string>

Methods

grep()

public static grep(string $pattern, array<string|int, T$array[, int $flags = 0 ]) : array<string|int, T>
Parameters
$pattern : string
$array : array<string|int, T>
$flags : int = 0
Tags
template

T of string|\Stringable

Return values
array<string|int, T>

isMatch()

Variant of match() which returns a bool instead of int

public static isMatch(non-empty-string $pattern, string $subject[, array<string|int, mixed> &$matches = null ][, int $flags = 0 ][, int $offset = 0 ]) : bool
Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed> = null

Set by method

$flags : int = 0
$offset : int = 0
Tags
param-out

array<int|string, string|null> $matches

Return values
bool

isMatchAll()

Variant of matchAll() which returns a bool instead of int

public static isMatchAll(non-empty-string $pattern, string $subject[, array<string|int, mixed> &$matches = null ][, int $flags = 0 ][, int $offset = 0 ]) : bool
Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed> = null

Set by method

$flags : int = 0
$offset : int = 0
Tags
param-out

array<int|string, list<string|null>> $matches

Return values
bool

isMatchAllStrictGroups()

Variant of `isMatchAll()` which outputs non-null matches (or throws)

public static isMatchAllStrictGroups(non-empty-string $pattern, string $subject[, array<string|int, mixed> &$matches = null ][, int $flags = 0 ][, int $offset = 0 ]) : bool
Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed> = null

Set by method

$flags : int = 0
$offset : int = 0
Tags
param-out

array<int|string, list> $matches

Return values
bool

isMatchAllWithOffsets()

Variant of matchAllWithOffsets() which returns a bool instead of int

public static isMatchAllWithOffsets(non-empty-string $pattern, string $subject, array<string|int, mixed> &$matches[, int $flags = 0 ][, int $offset = 0 ]) : bool

Runs preg_match_all with PREG_OFFSET_CAPTURE

Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed>

Set by method

$flags : int = 0
$offset : int = 0
Tags
param-out

array<int|string, list<array{string|null, int<-1, max>}>> $matches

Return values
bool

isMatchStrictGroups()

Variant of `isMatch()` which outputs non-null matches (or throws)

public static isMatchStrictGroups(non-empty-string $pattern, string $subject[, array<string|int, mixed> &$matches = null ][, int $flags = 0 ][, int $offset = 0 ]) : bool
Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed> = null

Set by method

$flags : int = 0
$offset : int = 0
Tags
throws
UnexpectedNullMatchException
param-out

array<int|string, string> $matches

Return values
bool

isMatchWithOffsets()

Variant of matchWithOffsets() which returns a bool instead of int

public static isMatchWithOffsets(non-empty-string $pattern, string $subject, array<string|int, mixed> &$matches[, int $flags = 0 ][, int $offset = 0 ]) : bool

Runs preg_match with PREG_OFFSET_CAPTURE

Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed>

Set by method

$flags : int = 0
$offset : int = 0
Tags
param-out

array<int|string, array{string|null, int<-1, max>}> $matches

Return values
bool

match()

public static match(non-empty-string $pattern, string $subject[, array<string|int, mixed> &$matches = null ][, int $flags = 0 ][, int $offset = 0 ]) : 0|1
Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed> = null

Set by method

$flags : int = 0
$offset : int = 0
Tags
param-out

array<int|string, string|null> $matches

Return values
0|1

matchAll()

public static matchAll(non-empty-string $pattern, string $subject[, array<string|int, mixed> &$matches = null ][, int $flags = 0 ][, int $offset = 0 ]) : 0|positive-int
Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed> = null

Set by method

$flags : int = 0
$offset : int = 0
Tags
param-out

array<int|string, list<string|null>> $matches

Return values
0|positive-int

matchAllStrictGroups()

Variant of `match()` which outputs non-null matches (or throws)

public static matchAllStrictGroups(non-empty-string $pattern, string $subject[, array<string|int, mixed> &$matches = null ][, int $flags = 0 ][, int $offset = 0 ]) : 0|positive-int
Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed> = null

Set by method

$flags : int = 0
$offset : int = 0
Tags
throws
UnexpectedNullMatchException
param-out

array<int|string, list> $matches

Return values
0|positive-int

matchAllWithOffsets()

Runs preg_match_all with PREG_OFFSET_CAPTURE

public static matchAllWithOffsets(non-empty-string $pattern, string $subject, array<string|int, mixed> &$matches[, int $flags = 0 ][, int $offset = 0 ]) : 0|positive-int
Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed>

Set by method

$flags : int = 0
$offset : int = 0
Tags
param-out

array<int|string, list<array{string|null, int<-1, max>}>> $matches

Return values
0|positive-int

matchStrictGroups()

Variant of `match()` which outputs non-null matches (or throws)

public static matchStrictGroups(non-empty-string $pattern, string $subject[, array<string|int, mixed> &$matches = null ][, int $flags = 0 ][, int $offset = 0 ]) : 0|1
Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed> = null

Set by method

$flags : int = 0
$offset : int = 0
Tags
throws
UnexpectedNullMatchException
param-out

array<int|string, string> $matches

Return values
0|1

matchWithOffsets()

Runs preg_match with PREG_OFFSET_CAPTURE

public static matchWithOffsets(non-empty-string $pattern, string $subject, array<string|int, mixed> &$matches[, int $flags = 0 ][, int $offset = 0 ]) : 0|1
Parameters
$pattern : non-empty-string
$subject : string
$matches : array<string|int, mixed>

Set by method

$flags : int = 0
$offset : int = 0
Tags
param-out

array<int|string, array{string|null, int<-1, max>}> $matches

Return values
0|1

replace()

public static replace(string|array<string|int, string> $pattern, string|array<string|int, string> $replacement, string $subject[, int $limit = -1 ][, int &$count = null ]) : string
Parameters
$pattern : string|array<string|int, string>
$replacement : string|array<string|int, string>
$subject : string
$limit : int = -1
$count : int = null

Set by method

Tags
param-out

int<0, max> $count

Return values
string

replaceCallback()

public static replaceCallback(string|array<string|int, string> $pattern, mixed $replacement, string $subject[, int $limit = -1 ][, int &$count = null ][, int $flags = 0 ]) : string
Parameters
$pattern : string|array<string|int, string>
$replacement : mixed
$subject : string
$limit : int = -1
$count : int = null

Set by method

$flags : int = 0
Tags
param-out

int<0, max> $count

Return values
string

replaceCallbackArray()

public static replaceCallbackArray(mixed $pattern, string $subject[, int $limit = -1 ][, int &$count = null ][, int $flags = 0 ]) : string
Parameters
$pattern : mixed
$subject : string
$limit : int = -1
$count : int = null

Set by method

$flags : int = 0
Tags
param-out

int<0, max> $count

Return values
string

replaceCallbackStrictGroups()

Variant of `replaceCallback()` which outputs non-null matches (or throws)

public static replaceCallbackStrictGroups(string $pattern, mixed $replacement, string $subject[, int $limit = -1 ][, int &$count = null ][, int $flags = 0 ]) : string
Parameters
$pattern : string
$replacement : mixed
$subject : string
$limit : int = -1
$count : int = null

Set by method

$flags : int = 0
Tags
param-out

int<0, max> $count

Return values
string

split()

public static split(string $pattern, string $subject[, int $limit = -1 ][, int $flags = 0 ]) : array<int, string>
Parameters
$pattern : string
$subject : string
$limit : int = -1
$flags : int = 0
Return values
array<int, string>

splitWithOffsets()

public static splitWithOffsets(string $pattern, string $subject[, int $limit = -1 ][, int $flags = 0 ]) : array<int, array{: string, : int}>
Parameters
$pattern : string
$subject : string
$limit : int = -1
$flags : int = 0
Tags
phpstan-return

list<array{string, int<0, max>}>

Return values
array<int, array{: string, : int}>

checkOffsetCapture()

private static checkOffsetCapture(int $flags, string $useFunctionName) : void
Parameters
$flags : int
$useFunctionName : string

checkSetOrder()

private static checkSetOrder(int $flags) : void
Parameters
$flags : int

enforceNonNullMatchAll()

private static enforceNonNullMatchAll(string $pattern, array<int|string, array<int, string|null>> $matches, string $variantMethod) : array<int|string, array<int, string>>
Parameters
$pattern : string
$matches : array<int|string, array<int, string|null>>
$variantMethod : string
Tags
throws
UnexpectedNullMatchException
Return values
array<int|string, array<int, string>>

enforceNonNullMatches()

private static enforceNonNullMatches(string $pattern, array<int|string, string|null|array{: string|null, : int}> $matches, string $variantMethod) : array<int|string, string>
Parameters
$pattern : string
$matches : array<int|string, string|null|array{: string|null, : int}>
$variantMethod : string
Tags
throws
UnexpectedNullMatchException
Return values
array<int|string, string>

        
On this page

Search results