• 正则函数[原则,能用字符串函数解决不用正则,速度问题]s


    <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里的元素按照“+”链接成一个字符串
  • 相关阅读:
    Redis分布式锁的正确实现方式
    Redis+Jedis封装工具类
    MyCat配置文件详解--server.xml
    linux buff/cache释放
    mycat中间件--schema.xml配置文件详解
    mycat中间件--linux安装mycat1.6版本
    如何查找SHELL的进程号并杀死
    dubbo常用配置及注意事项
    xxxx
    解决docker镜像无法下载的问题
  • 原文地址:https://www.cnblogs.com/zq1040657944/p/13340201.html
Copyright © 2020-2023  润新知