| @@ 418-435 (lines=18) @@ | ||
| 415 | * |
|
| 416 | * @return self |
|
| 417 | */ |
|
| 418 | public function pregReplace( |
|
| 419 | string $regex, |
|
| 420 | string $replacement, |
|
| 421 | int $limit = -1 |
|
| 422 | ): self { |
|
| 423 | $value = preg_replace( |
|
| 424 | $regex, |
|
| 425 | $replacement, |
|
| 426 | $this->value, |
|
| 427 | $limit |
|
| 428 | ); |
|
| 429 | ||
| 430 | if ($value === null) { |
|
| 431 | throw new RegexException('', preg_last_error()); |
|
| 432 | } |
|
| 433 | ||
| 434 | return new self($value); |
|
| 435 | } |
|
| 436 | ||
| 437 | /** |
|
| 438 | * Return part of the string |
|
| @@ 447-461 (lines=15) @@ | ||
| 444 | * |
|
| 445 | * @return self |
|
| 446 | */ |
|
| 447 | public function pregReplace(string $regex, string $replacement, int $limit = -1): self |
|
| 448 | { |
|
| 449 | $value = preg_replace( |
|
| 450 | $regex, |
|
| 451 | $replacement, |
|
| 452 | $this->value, |
|
| 453 | $limit |
|
| 454 | ); |
|
| 455 | ||
| 456 | if ($value === null) { |
|
| 457 | throw new RegexException('', preg_last_error()); |
|
| 458 | } |
|
| 459 | ||
| 460 | return new self($value); |
|
| 461 | } |
|
| 462 | ||
| 463 | /** |
|
| 464 | * Return part of the string |
|