php正则之函数 preg_replace()参数说明
网络编程
preg_replace
字符串比对解析并取代。
语法: mixed preg_replace(mixed pattern, mixed replacement, mixed subject);
返回值: 混合类型资料
函数种类: 资料处理
内容说明
本函数以 pattern 的规则来解析比对字符串 subject,欲取而代之的字符串为参数 replacement。返回值为混合类型资料,为取代后的字符串结果。
使用范例
下例返回值为 $startDate = 6/19/1969
字符串比对解析并取代。
语法: mixed preg_replace(mixed pattern, mixed replacement, mixed subject);
返回值: 混合类型资料
函数种类: 资料处理
内容说明
本函数以 pattern 的规则来解析比对字符串 subject,欲取而代之的字符串为参数 replacement。返回值为混合类型资料,为取代后的字符串结果。
使用范例
下例返回值为 $startDate = 6/19/1969
<?php
$patterns = array("/(19|20d{2})-(d{1,2})-(d{1,2})/", "/^s*{(w+)}s*=/");
$replace = array("\3/\4/\1", "$\1 =");
print preg_replace($patterns, $replace, "{startDate} = 1969-6-19");
?>
关于preg_replace函数的问题讲解
请问下那此句语句的作用。给我解释一下其中的?,e","i","s"符号分别是什么意思,和它们起到了什么作用。还有就是除了"/eis外还有其他什么模式了吗
自定义ubb代码,preg_replace()函数的一些代码
functionubb($Text){$Text=htmlspecialchars($Text);$Text=ereg_replace("rn","br",$Text);$Text=ereg_replace("r","br",$Text);$Text=nl2br($Text);$Text=preg_replace("/\t/is","",$Text);$Text=preg_replace(
eregi_replace()中特殊字符的处理方法
我对PHP的正则表达式不太熟悉在使用eregi_replace()函数时发现带有()的字符串不能进行替换,看了手册还是糊里糊涂比如将DIN1693(Pt.2)-1997加粗使用$str='di
编辑:一起学习网
标签:字符串,函数,资料,值为,比对