标签:str 结果 span col replace ace php 正则表达 div
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 cats
this is four cats
this was 4 cats
括号可以嵌套,此情形下以左圆括号来计算顺序。
标签:str 结果 span col replace ace php 正则表达 div
原文地址:http://www.cnblogs.com/Horsonce/p/7613868.html