Bolt\Twig\Handler\TextHandler::pregReplace PHP Метод

pregReplace() публичный Метод

Perform a regular expression search and replace on the given string.
public pregReplace ( string $str, string $pattern, string $replacement = '', integer $limit ) : string
$str string
$pattern string
$replacement string
$limit integer
Результат string Same string where first character is in upper case
    public function pregReplace($str, $pattern, $replacement = '', $limit = -1)
    {
        return preg_replace($pattern, $replacement, $str, $limit);
    }

Usage Example

Пример #1
0
 public function testPregReplaceWithReplacementWithLimit()
 {
     $app = $this->getApp();
     $handler = new TextHandler($app);
     $result = $handler->pregReplace('One koala, two koalas, three koalas, four!', '#(ko)a(la|las)#', 'clippy', 2);
     $this->assertSame('One clippy, two clippys, three koalas, four!', $result);
 }