码迷,mamicode.com
首页 >  
搜索关键字:preg_replace    ( 214个结果
PHP过滤常用的标签
<?php $str=preg_replace("/\s+/",?"?",?$str);?//过滤多余回车 $str=preg_replace("/<[?]+/si","<",$str);?//过滤<__("<"号后面带空格) $str=preg_replace("/<\!–.*?–>/si","",$str);?//注释 $str=pre...
分类:Web程序   时间:2015-07-07 13:21:10    阅读次数:139
PHP去除unicode续:json_encode之后,只有文字,数字不见了的解决方法
接前文,http://blog.csdn.net/yanzi1225627/article/details/44985487 这么处理了一段时间,确实没发现问题。但最近发现了一个bug,比如输入”我是123”, 这么json_encode 之后,再 preg_replace 一下,就变成了”我是”,数字不见了。 纠结了一番,是这个替换的方法不对,将原来的:preg_replace("#\\...
分类:Web程序   时间:2015-07-05 09:37:10    阅读次数:123
preg_replace 的使用
先看手册...仔细看http://php.net/manual/zh/function.preg-replace.php是不是对向后引用有点糊涂?继续看http://deerchao.net/tutorials/regex/regex.htm主要看后向引用 那一栏看懂了吗?是的!分组是由 () 来确...
分类:其他好文   时间:2015-07-04 00:48:06    阅读次数:132
PHP基础示例:用正则表达式修改配置信息
各php工作原理图:以下是扯代码时间: $v){ $info=preg_replace("/define\(\"{$k}\",\"(.*?)\"\)/","define(\"{$k}\",\"{$v}\")",$info);}//3.将替换后的信息写回到配置文件中file_put_conten...
分类:Web程序   时间:2015-06-02 23:20:08    阅读次数:165
str_replace vs preg_replace
转自:http://benchmarks.ro/2011/02/str_replace-vs-preg_replace/事实证明str_replace确实比preg_replace快。If you find yourself handling strings and replacing sub-st...
分类:其他好文   时间:2015-05-27 18:51:53    阅读次数:121
php_公共方法01_传入数组_打印可见信息
function decodeUnicode($str) {return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'convert', $str);}function convert($matches){return mb_convert_enc...
分类:编程语言   时间:2015-05-20 22:18:30    阅读次数:164
php json 初始化函数(格式化json字符串为php json_decode 标准的字符串)
$json="[{ 'i':100000, 'u':-1,n: '中国'},{i:100001,u:-1,n:'阿尔巴尼亚'},{i:100002,u:-1,n:'阿尔及利亚',}]";$json = preg_replace('/([{,:])(\s*)\'(.*?)\'/','$1"$3"...
分类:Web程序   时间:2015-04-17 17:12:40    阅读次数:169
preg_replace 方法
标红关键字$text = "Sample sentence from KomunitasWeb, regex has become popular in web programming. Now we learn regex. According to wikipedia, Regular expr...
分类:其他好文   时间:2015-04-16 13:47:01    阅读次数:144
php过滤HTML标签、属性等正则表达式汇总
$str=preg_replace("/\s+/", " ", $str); //过滤多余回车$str=preg_replace("//si","",$str); //注释$str=preg_replace("//si","",$str); //过滤DOCTYPE$str=preg_replace(...
分类:Web程序   时间:2015-04-16 12:24:17    阅读次数:145
正则匹配 去掉 多余的js和html标签
1 $reg17 = '/>公司介绍([\S\s*]+?)/';2 3 $this->data['introduction'] = preg_replace("''is","",$this->data['introduction']);4 5 $this->data['introduction']=...
分类:Web程序   时间:2015-04-14 00:13:52    阅读次数:145
214条   上一页 1 ... 14 15 16 17 18 ... 22 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!