ZF-10822: Invalid example in Zend_Filter_PregReplace documentation

Description

In this page : http://framework.zend.com/manual/en/… the code sample below:

<?php $filter = new Zend_Filter_PregReplace(array('match' => 'bob', 'replace' => 'john')); $input = 'Hy bob!"; $filter->filter($input); // returns 'Hy john!' ?>

Contains 2 errors: - 'Hy bob!" begins with a single quote and ends with a double quote - 'match' => 'bob' triggers a "Delimiter must not be alphanumeric" error

Proposed fixed example:

<?php $filter = new Zend_Filter_PregReplace(array('match' => '/bob/', 'replace' => 'john')); $input = 'Hy bob!'; $filter->filter($input); // returns 'Hy john!' ?>

Comments

patch attached

Mixed up two patches in last patch file. This one is correct.

[SVN:r23520:bittarman] ZF-10822: merging r23519 to release branch 1.11 (See: http://tinyurl.com/2bc7k25)

Why is it reopened?

There is still a problem on the second example, just below:

$filter = new Zend_Filter_PregReplace(); $filter->setMatchPattern(array('bob', 'Hy')) ->setReplacement(array('john', 'Bye')); $input = 'Hy bob!";

$filter->filter($input);

Should be:

$filter = new Zend_Filter_PregReplace(); $filter->setMatchPattern(array('/bob/', '/Hy/')) ->setReplacement(array('john', 'Bye'));

$input = 'Hy bob!';

$filter->filter($input);

Fixed with GH-92