Examples::
String.pregReplace("Some.String with sp:cial characters", "/[[:^alnum:]]/", "-") == "Some-String-with-sp-cial-characters"
String.pregReplace("2016-08-31", "/([0-9]+)-([0-9]+)-([0-9]+)/", "$3.$2.$1") == "31.08.2016"
/** * @test * @dataProvider pregReplaceExamples */ public function pregReplaceWorks($string, $pattern, $replace, $expected) { $helper = new StringHelper(); $result = $helper->pregReplace($string, $pattern, $replace); $this->assertSame($expected, $result); }