. .

PHP

» PHP 5 »

, . ereg_replace() eregi_replace() - 15.7.

15.7. .

‹html›
‹head›
‹title› ‹/title›
‹/head›
‹body›
‹?php
$str = "His name is Bob. Bob is my friend.";
$patt = "Bob";
$str_repl = "Bill";
// "His name is Bill. Bill is my friend."
echo ereg_replace ($patt, $str_repl, $str);
?›
‹/body›
‹/html›

$str , $patt, $str_replace. ereg_replace() . His name is Bill. Bill is my friend. , , .

ereg_ replace() , ( 15.8).

15.8. .

‹html›
‹head›
‹title› ‹/title›
‹/head›
‹body›
‹?php
$str = " 14:07:23";
$patt = "([0-1][0-9]|[0-2][0-4]):([0-5][0-9]):([0-5][0-9])";
$str_repl = "\\1 \\2 \\3 ";
// 14 07 23
echo eregi_replace($patt, $str_repl, $str);
?›
‹/body›
‹/html›

$str_repl (\\1, \\2 \\3). ereg_replace() , , . 0 9. \\0 - 15.9.

15.9. .

‹html›
‹head›
‹title› ‹/title›
‹/head›
‹body›
‹?php
$str = "His name is Bon.";
$patt = "Bon";
$str_repl = "\\0-\\0";
// "His name is Bon-Bon"
echo ereg_replace ($patt, $str_repl, $str);
?›
‹/body›
‹/html›

, , , eregi_replace() ereg_replace(), .