preg_replace_basic.phpt [plain text]
--TEST--
Test preg_replace() function : basic functionality
--FILE--
<?php
$string = '123456789 - Hello, world - This is a string.';
var_dump($string);
var_dump(preg_replace('<- This is a string$>', 'This shouldn\'t work', $string)); var_dump(preg_replace('<[0-35-9]>', '4', $string)); var_dump(preg_replace('<\b[hH]\w{2,4}>', 'Bonjour', $string)); var_dump(preg_replace('<(\w)\s*-\s*(\w)>', '\\1. \\2', $string)); var_dump(preg_replace('<(^[a-z]\w+)@(\w+)\.(\w+)\.([a-z]{2,}$)>', '\\1 at \\2 dot \\3 dot \\4', 'josmessa@uk.ibm.com'));
?>
--EXPECT--
string(54) "123456789 - Hello, world - This is a string."
string(54) "123456789 - Hello, world - This is a string."
string(54) "444444444 - Hello, world - This is a string."
string(56) "123456789 - Bonjour, world - This is a string."
string(42) "123456789. Hello, world. This is a string."
string(30) "josmessa at uk dot ibm dot com"