°渐行渐远っ
程序员的修仙之路
<h1>本文摘之http://blog.csdn.net/ty_hf/article/details/49641921<h1>
正则函数[
原则,能用字符串函数解决不用正则,速度问题]
        字符串的匹配查找
            1.preg_match($pattern,$subject,$arr);//按正则$pattern处理$subject,第一次匹配结果返回到数组中【函数的返回值为匹配次数】
            2.preg_match_all($pattern,$subject,$arr)//按正则$pattern处理$subject,全部匹配结果返回到数组中【函数的返回值为匹配次数
            3.strstr($str,"@"[,true]);
            4.strpos,strrpos,substr($str,position)//联合使用
         字符串的替换
            1.preg_replace($pattenr,$replace,$str);//【强大的字符串处理函数】
                        在$str中,把$parrern匹配的值替换成$replcae【返回值为处理后的字符串】
            2.str_replace($str,"aaa","bbb");//把$str中的aaa换成bbb
         字符串的分割和链接
            1.preg_split($pattern,$str);通过一个正则表达式分隔字符串【返回值为数组】                        
                        举例:$keywords preg_split("/[\s,]+/""hypertext language, programming");
            结果Array([0] => hypertext,[1] => language[2] => programming)
            2.explode(",",$str[,$limit_num]);//把$str按照","分割成一个数组[可选参数为返回数组的元素个数]【返回一个分割后的数组】
            3.impolde("+",$arr);//把$arr里的元素按照“+”链接成一个字符串
posted on 2017-06-26 12:00  &#176;渐行渐远っ  阅读(62)  评论(0编辑  收藏  举报