'hemmo wormd', 3, 'hello world', 'l', 'm'
],
['hello world', 0, 'hello world', 'L', 'm'
],
];
} /**
* @dataProvider provideReplaceMatches
*/
public function testReplaceMatches(string
$expectedString, string
$origin, string
$fromRegexp,
$to) { $origin =
static::
createFromString($origin);
$result =
$origin->
replaceMatches($fromRegexp,
$to);
$this->
assertEquals(static::
createFromString($expectedString),
$result);
} public static function provideReplaceMatches() { return [ ['April,15,2003', 'April 15, 2003', '/(\w+) (\d+), (\d+)/i', '${1},$2,$3'
],
['5/27/1999', '1999-5-27', '/(19|20)(\d{2})-(\d{1,2})-(\d{1,2})/', '\3/\4/\1\2'
],
['Copyright 2000', 'Copyright 1999', '([0-9]+)', '2000'
],
['hello world! this is a test', 'HELLO WORLD! THIS is a test', '/\b([A-Z]+)\b/',
fn ($word) =>
strtolower($word[1
])],
[