Preg
in package
Table of Contents
- ARRAY_MSG = '$subject as an array is not supported. You can use 'foreach' instead.'
- grep() : array<string|int, T>
- isMatch() : bool
- isMatchAll() : bool
- isMatchAllWithOffsets() : bool
- Runs preg_match_all with PREG_OFFSET_CAPTURE
- isMatchWithOffsets() : bool
- Runs preg_match with PREG_OFFSET_CAPTURE
- match() : 0|1
- matchAll() : mixed
- matchAllWithOffsets() : mixed
- Runs preg_match_all with PREG_OFFSET_CAPTURE
- matchWithOffsets() : 0|1
- Runs preg_match with PREG_OFFSET_CAPTURE
- replace() : string
- replaceCallback() : string
- replaceCallbackArray() : string
- Available from PHP 7.0
- split() : list<string|int, string>
- splitWithOffsets() : mixed
Constants
ARRAY_MSG
public
mixed
ARRAY_MSG
= '$subject as an array is not supported. You can use 'foreach' instead.'
Methods
grep()
public
static grep(string $pattern, array<string|int, T> $array, int $flags) : array<string|int, T>
Parameters
- $pattern : string
- $array : array<string|int, T>
- $flags : int
-
PREG_GREP_INVERT
Tags
Return values
array<string|int, T> —isMatch()
public
static isMatch(mixed $pattern, string $subject[, array<string|int, string|null> &$matches = null ], int $flags, int $offset) : bool
Parameters
- $pattern : mixed
- $subject : string
- $matches : array<string|int, string|null> = null
-
Set by method
- $flags : int
-
PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
- $offset : int
Return values
bool —isMatchAll()
public
static isMatchAll(mixed $pattern, string $subject[, array<int|string, list<string|int, string|null>> &$matches = null ], int $flags, int $offset) : bool
Parameters
- $pattern : mixed
- $subject : string
- $matches : array<int|string, list<string|int, string|null>> = null
-
Set by method
- $flags : int
-
PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
- $offset : int
Return values
bool —isMatchAllWithOffsets()
Runs preg_match_all with PREG_OFFSET_CAPTURE
public
static isMatchAllWithOffsets(mixed $pattern, string $subject, mixed &$matches, int $flags, int $offset) : bool
Parameters
- $pattern : mixed
- $subject : string
- $matches : mixed
- $flags : int
-
PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
- $offset : int
Tags
Return values
bool —isMatchWithOffsets()
Runs preg_match with PREG_OFFSET_CAPTURE
public
static isMatchWithOffsets(mixed $pattern, string $subject, mixed &$matches, int $flags, int $offset) : bool
Parameters
- $pattern : mixed
- $subject : string
- $matches : mixed
- $flags : int
-
PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
- $offset : int
Tags
Return values
bool —match()
public
static match(mixed $pattern, string $subject[, array<string|int, string|null> &$matches = null ], int $flags, int $offset) : 0|1
Parameters
- $pattern : mixed
- $subject : string
- $matches : array<string|int, string|null> = null
-
Set by method
- $flags : int
-
PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
- $offset : int
Return values
0|1 —matchAll()
public
static matchAll(mixed $pattern, string $subject[, array<int|string, list<string|int, string|null>> &$matches = null ], int $flags, int $offset) : mixed
Parameters
- $pattern : mixed
- $subject : string
- $matches : array<int|string, list<string|int, string|null>> = null
-
Set by method
- $flags : int
-
PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
- $offset : int
Return values
mixed —matchAllWithOffsets()
Runs preg_match_all with PREG_OFFSET_CAPTURE
public
static matchAllWithOffsets(mixed $pattern, string $subject, mixed &$matches, int $flags, int $offset) : mixed
Parameters
- $pattern : mixed
- $subject : string
- $matches : mixed
- $flags : int
-
PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
- $offset : int
Tags
Return values
mixed —matchWithOffsets()
Runs preg_match with PREG_OFFSET_CAPTURE
public
static matchWithOffsets(mixed $pattern, string $subject, mixed &$matches, int $flags, int $offset) : 0|1
Parameters
- $pattern : mixed
- $subject : string
- $matches : mixed
- $flags : int
-
PREG_UNMATCHED_AS_NULL, only available on PHP 7.2+
- $offset : int
Tags
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
Return values
string —replaceCallback()
public
static replaceCallback(string|array<string|int, string> $pattern, callable $replacement, string $subject[, int $limit = -1 ][, int &$count = null ], int $flags) : string
Parameters
- $pattern : string|array<string|int, string>
- $replacement : callable
- $subject : string
- $limit : int = -1
- $count : int = null
-
Set by method
- $flags : int
-
PREG_OFFSET_CAPTURE or PREG_UNMATCHED_AS_NULL, only available on PHP 7.4+
Return values
string —replaceCallbackArray()
Available from PHP 7.0
public
static replaceCallbackArray(array<string, callable> $pattern, string $subject[, int $limit = -1 ][, int &$count = null ], int $flags) : string
Parameters
- $pattern : array<string, callable>
- $subject : string
- $limit : int = -1
- $count : int = null
-
Set by method
- $flags : int
-
PREG_OFFSET_CAPTURE or PREG_UNMATCHED_AS_NULL, only available on PHP 7.4+
Return values
string —split()
public
static split(string $pattern, string $subject[, int $limit = -1 ], int $flags) : list<string|int, string>
Parameters
- $pattern : string
- $subject : string
- $limit : int = -1
- $flags : int
-
PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE
Return values
list<string|int, string> —splitWithOffsets()
public
static splitWithOffsets(string $pattern, string $subject[, int $limit = -1 ], int $flags) : mixed
Parameters
- $pattern : string
- $subject : string
- $limit : int = -1
- $flags : int
-
PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE