php中正则替换函数ereg_replace用法实例
编程学习 2021-07-05 10:07www.dzhlxh.cn编程入门
这篇文章主要介绍了php中正则替换函数ereg_replace用法,以实例形式分析了ereg_replace函数进行正则替换时的用法,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了php中正则替换函数ereg_replace用法。分享给大家供大家参考。具体如下:
狼蚁网站SEO优化的实例是利用php 正则替换函数 ereg_replace来把指定的字符替换成我想需要的字符实例,代码如下:
代码如下:
$num = 'www.jb51.net';
$string = "this string has four words. <br>";
$string = ereg_replace ('four', $num, $string);
echo $string;
$string = "this string has four words. <br>";
$string = ereg_replace ('four', $num, $string);
echo $string;
$num = '49';
$string = "this string has four words";
$string = ereg_replace ('four', $num, $string);
echo $string;
$string ="测试用文字";
echo "**********$string**********<p>";
$string = ereg_replace ("^", "<br>", $string);
$string = ereg_replace ("$", "<br>", $string);
echo "==========$string==========";
希望本文所述对大家的正则表达式学习有所帮助。