| @@ 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 |
|
| @@ 417-434 (lines=18) @@ | ||
| 414 | * |
|
| 415 | * @return self |
|
| 416 | */ |
|
| 417 | public function pregReplace( |
|
| 418 | string $regex, |
|
| 419 | string $replacement, |
|
| 420 | int $limit = -1 |
|
| 421 | ): self { |
|
| 422 | $value = preg_replace( |
|
| 423 | $regex, |
|
| 424 | $replacement, |
|
| 425 | $this->value, |
|
| 426 | $limit |
|
| 427 | ); |
|
| 428 | ||
| 429 | if ($value === null) { |
|
| 430 | throw new RegexException('', preg_last_error()); |
|
| 431 | } |
|
| 432 | ||
| 433 | return new self($value); |
|
| 434 | } |
|
| 435 | ||
| 436 | /** |
|
| 437 | * Return part of the string |
|