php中正则替换函数ereg_replace用法实例
作者:shichen2014 时间:2023-06-13 03:03:51
本文实例讲述了php中正则替换函数ereg_replace用法。分享给大家供大家参考。具体如下:
下面的实例是利用php 正则替换函数 ereg_replace来把指定的字符替换成我想需要的字符实例,代码如下:
$num = 'www.jb51.net';
$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==========";
希望本文所述对大家的正则表达式学习有所帮助。
标签:php,正则,替换
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python turtle库画圣诞树详细代码教程
2022-09-20 10:29:33
![](https://img.aspxhome.com/file/2023/4/97354_0s.png)
JS+ASP实现无刷新新闻列表方法
2007-08-22 12:44:00
Python源码学习之PyObject和PyTypeObject
2023-08-11 10:28:45
![](https://img.aspxhome.com/file/2023/2/62252_0s.png)
Perl使用Tesseract-OCR实现验证码识别教程
2022-04-22 07:52:05
教你用python将数据写入Excel文件中
2021-12-29 03:28:38
![](https://img.aspxhome.com/file/2023/8/97638_0s.png)
Python实现的多项式拟合功能示例【基于matplotlib】
2022-02-18 14:44:08
![](https://img.aspxhome.com/file/2023/7/117897_0s.png)
golang中使用sync.Map的方法
2024-02-08 13:50:40
javascript trim、left、right等函数,兼容IE,FireFox
2009-09-18 14:55:00
Python构建区块链的方法详解
2021-01-07 07:20:55
![](https://img.aspxhome.com/file/2023/5/99045_0s.png)
mysql UNIX时间戳与日期的相互转换
2010-02-10 12:10:00
SQL 无法装载DLL Microsoft原因(无法修改sa密码)
2024-01-19 21:04:57
使用Python爬取最好大学网大学排名
2023-09-17 09:24:45
用Go写一个轻量级的ssh批量操作工具的方法
2024-05-21 10:28:04
各种 lightbox 实现效果介绍
2007-11-06 19:16:00
更改SQL Server 2005数据库中tempdb位置的方法
2024-01-25 17:46:35
在Python 中同一个类两个函数间变量的调用方法
2022-07-02 04:53:57
![](https://img.aspxhome.com/file/2023/2/101602_0s.jpg)
vscode 配置eslint和prettier正确方法
2022-12-31 04:54:44
![](https://img.aspxhome.com/file/2023/4/114704_0s.png)
SQL Server的复制功能
2024-01-16 19:40:27
![](https://img.aspxhome.com/file/2023/1/94401_0s.jpg)
asp.net性能的技巧
2007-10-07 21:55:00
Django 数据库同步操作技巧详解
2024-01-28 02:26:14
![](https://img.aspxhome.com/file/2023/5/112545_0s.png)