zoukankan      html  css  js  c++  java
  • 正则函数[原则,能用字符串函数解决不用正则,速度问题]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里的元素按照“+”链接成一个字符串
  • 相关阅读:
    移动端meta标签
    document.ready 和 window.onload
    axios 源码分析
    vue 中的 el
    安卓和Ios 手机兼容性
    一些移动端问题
    Python 局部变量与全局变量
    Linux常用命令大全(非常全!!!)
    Python_爬虫_基础
    linux 常用命令
  • 原文地址:https://www.cnblogs.com/zq1040657944/p/13340201.html
Copyright © 2011-2022 走看看