<?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
接前文,http://blog.csdn.net/yanzi1225627/article/details/44985487 这么处理了一段时间,确实没发现问题。但最近发现了一个bug,比如输入”我是123”, 这么json_encode 之后,再 preg_replace 一下,就变成了”我是”,数字不见了。
纠结了一番,是这个替换的方法不对,将原来的:preg_replace("#\\...
分类:
Web程序 时间:
2015-07-05 09:37:10
阅读次数:
123
先看手册...仔细看http://php.net/manual/zh/function.preg-replace.php是不是对向后引用有点糊涂?继续看http://deerchao.net/tutorials/regex/regex.htm主要看后向引用 那一栏看懂了吗?是的!分组是由 () 来确...
分类:
其他好文 时间:
2015-07-04 00:48:06
阅读次数:
132
各php工作原理图:以下是扯代码时间: $v){ $info=preg_replace("/define\(\"{$k}\",\"(.*?)\"\)/","define(\"{$k}\",\"{$v}\")",$info);}//3.将替换后的信息写回到配置文件中file_put_conten...
分类:
Web程序 时间:
2015-06-02 23:20:08
阅读次数:
165
转自: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
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
$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
标红关键字$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
$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
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