ereg_replace — 正则表达式替换
string ereg_replace ( string $pattern
, string $replacement
, string $string
)
代码:
<?php ???$num="4"; ???$string="this was four cats"; ???????$str=ereg_replace(‘()was‘,‘\\1is‘, $string); ???$str1=str_replace(‘was‘,‘is‘,$string); ???$str2=ereg_replace(‘four‘,$num, $string); ???echo $str.‘<br>‘; ???echo $str1.‘<br>‘; ???echo $str2.‘<br>‘; ????>
输出结果:
this is four catsthis is four catsthis was 4 cats
括号可以嵌套,此情形下以左圆括号来计算顺序。
【PHP】ereg_repalce( )
原文地址:http://www.cnblogs.com/Horsonce/p/7613868.html