|
@@ 32-40 (lines=9) @@
|
| 29 |
|
* @throws PcreRegexException When compilation or runtime error occurs |
| 30 |
|
* @link http://php.net/function.preg-match.php |
| 31 |
|
*/ |
| 32 |
|
public static function match($pattern, $subject, $offset = 0) |
| 33 |
|
{ |
| 34 |
|
static::setUp($pattern); |
| 35 |
|
$res = \preg_match($pattern, $subject, $matches, 0, $offset); |
| 36 |
|
static::tearDown(); |
| 37 |
|
static::handleError($pattern); |
| 38 |
|
|
| 39 |
|
return (bool) $res; |
| 40 |
|
} |
| 41 |
|
|
| 42 |
|
/** |
| 43 |
|
* Regular expression match and return first match. |
|
@@ 53-61 (lines=9) @@
|
| 50 |
|
* @throws PcreRegexException When compilation or runtime error occurs |
| 51 |
|
* @link http://php.net/function.preg-match.php |
| 52 |
|
*/ |
| 53 |
|
public static function get($pattern, $subject, $flags = 0, $offset = 0) |
| 54 |
|
{ |
| 55 |
|
static::setUp($pattern); |
| 56 |
|
\preg_match($pattern, $subject, $matches, $flags, $offset); |
| 57 |
|
static::tearDown(); |
| 58 |
|
static::handleError($pattern); |
| 59 |
|
|
| 60 |
|
return $matches; |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
/** |
| 64 |
|
* Global regular expression match and return all matches. |
|
@@ 74-82 (lines=9) @@
|
| 71 |
|
* @throws PcreRegexException When compilation or runtime error occurs |
| 72 |
|
* @link http://php.net/function.preg-match-all.php |
| 73 |
|
*/ |
| 74 |
|
public static function getAll($pattern, $subject, $flags = \PREG_PATTERN_ORDER, $offset = 0) |
| 75 |
|
{ |
| 76 |
|
static::setUp($pattern); |
| 77 |
|
\preg_match_all($pattern, $subject, $matches, $flags, $offset); |
| 78 |
|
static::tearDown(); |
| 79 |
|
static::handleError($pattern); |
| 80 |
|
|
| 81 |
|
return \array_filter($matches); |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
/** |
| 85 |
|
* Regular expression replace and return replaced. |
|
@@ 135-143 (lines=9) @@
|
| 132 |
|
* @throws PcreRegexException When compilation or runtime error occurs |
| 133 |
|
* @link http://php.net/function.preg-split.php |
| 134 |
|
*/ |
| 135 |
|
public static function split($pattern, $subject, $limit = -1, $flags = \PREG_SPLIT_DELIM_CAPTURE) |
| 136 |
|
{ |
| 137 |
|
static::setUp($pattern); |
| 138 |
|
$res = \preg_split($pattern, $subject, $limit, $flags); |
| 139 |
|
static::tearDown(); |
| 140 |
|
static::handleError($pattern); |
| 141 |
|
|
| 142 |
|
return $res; |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
/** |
| 146 |
|
* Regular expression grep and return matching items. |
|
@@ 155-163 (lines=9) @@
|
| 152 |
|
* @throws PcreRegexException When compilation or runtime error occurs |
| 153 |
|
* @link http://php.net/function.preg-grep.php |
| 154 |
|
*/ |
| 155 |
|
public static function grep($pattern, $subject, $flags = 0) |
| 156 |
|
{ |
| 157 |
|
static::setUp($pattern); |
| 158 |
|
$res = \preg_grep($pattern, (array) $subject, $flags); |
| 159 |
|
static::tearDown(); |
| 160 |
|
static::handleError($pattern); |
| 161 |
|
|
| 162 |
|
return $res; |
| 163 |
|
} |
| 164 |
|
|
| 165 |
|
/** |
| 166 |
|
* Regular expression filter and return only replaced. |
|
@@ 176-184 (lines=9) @@
|
| 173 |
|
* @throws PcreRegexException When compilation or runtime error occurs |
| 174 |
|
* @link http://php.net/function.preg-filter.php |
| 175 |
|
*/ |
| 176 |
|
public static function filter($pattern, $replacement, $subject, $limit = -1) |
| 177 |
|
{ |
| 178 |
|
static::setUp($pattern); |
| 179 |
|
$res = \preg_filter($pattern, $replacement, $subject, $limit); |
| 180 |
|
static::tearDown(); |
| 181 |
|
static::handleError($pattern); |
| 182 |
|
|
| 183 |
|
return $res; |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
/** |
| 187 |
|
* Prepare error handler for catching compilation errors. |