preg_replace_edit_basic.phpt [plain text]
--TEST--
Test preg_replace() function : basic
--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, '5', $count)); var_dump($count);
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')); ?>
--EXPECTF--
string(54) "123456789 - Hello, world - This is a string."
string(54) "123456789 - Hello, world - This is a string."
string(54) "444444789 - Hello, world - This is a string."
int(5)
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"