mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Improved String::insert by support placeholders with after sequence during cleanup
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6869 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
7308c3e5d4
commit
72c37d429e
2 changed files with 8 additions and 6 deletions
|
@ -246,13 +246,15 @@ class String extends Object {
|
||||||
), $options);
|
), $options);
|
||||||
|
|
||||||
$kleenex = sprintf(
|
$kleenex = sprintf(
|
||||||
'/(%s%s%s|%s%s%s)/',
|
'/(%s%s%s%s|%s%s%s%s)/',
|
||||||
$options['before'],
|
preg_quote($options['before'], '/'),
|
||||||
$options['clean']['word'],
|
$options['clean']['word'],
|
||||||
|
preg_quote($options['after'], '/'),
|
||||||
$options['clean']['gap'],
|
$options['clean']['gap'],
|
||||||
$options['clean']['gap'],
|
$options['clean']['gap'],
|
||||||
$options['before'],
|
preg_quote($options['before'], '/'),
|
||||||
$options['clean']['word']
|
$options['clean']['word'],
|
||||||
|
preg_quote($options['after'], '/')
|
||||||
);
|
);
|
||||||
$str = preg_replace($kleenex, '', $str);
|
$str = preg_replace($kleenex, '', $str);
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,9 +121,9 @@ class StringTest extends UnitTestCase {
|
||||||
$result = String::insert($string, array('a' => 1, 'b' => 2), array('clean' => true));
|
$result = String::insert($string, array('a' => 1, 'b' => 2), array('clean' => true));
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$string = '":a, :b and :c"';
|
$string = '"${a}, ${b} and ${c}"';
|
||||||
$expected = '"1, 2"';
|
$expected = '"1, 2"';
|
||||||
$result = String::insert($string, array('a' => 1, 'b' => 2), array('clean' => true));
|
$result = String::insert($string, array('a' => 1, 'b' => 2), array('before' => '${', 'after' => '}', 'clean' => true));
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue