﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Jhon-文章分类-PHP</title><link>http://www.cppblog.com/Jhon/category/16064.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 25 Feb 2011 16:51:48 GMT</lastBuildDate><pubDate>Fri, 25 Feb 2011 16:51:48 GMT</pubDate><ttl>60</ttl><item><title>在secureCRT下，使用rz和sz命令上传和下载文件 【转】</title><link>http://www.cppblog.com/Jhon/articles/140638.html</link><dc:creator>lvweiqiu</dc:creator><author>lvweiqiu</author><pubDate>Fri, 25 Feb 2011 03:52:00 GMT</pubDate><guid>http://www.cppblog.com/Jhon/articles/140638.html</guid><wfw:comment>http://www.cppblog.com/Jhon/comments/140638.html</wfw:comment><comments>http://www.cppblog.com/Jhon/articles/140638.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Jhon/comments/commentRss/140638.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Jhon/services/trackbacks/140638.html</trackback:ping><description><![CDATA[<p>转：<a href="http://www.cppblog.com/zdhsoft/archive/2011/02/23/140499.html">http://www.cppblog.com/zdhsoft/archive/2011/02/23/140499.html</a><br>在这之前，一直用secureFX向linux传输文件。对于批量的，用它确实很方便。但是开发的时候，临时传送文件就不方便了。<br>我尝试ultraedit，但它下载和上传很慢（仅指我的环境很慢）。<br>后来，一同事说可以用命令来实现。于是我就知道这个东西了。知道了，就贴出来，希望能给大家一点帮助。<br>我这里使用的是secureCRT 6.5.2，linux是CentOS 5.5。这个地方可以下载secureCRT 6.5.2 <a href="http://download.csdn.net/source/2354726"><u><font color=#0066cc>http://download.csdn.net/source/2354726</font></u></a><br>配置上传下载目录：选择某个session 标签，<br><img border=0 alt="" src="http://www.cppblog.com/images/cppblog_com/zdhsoft/20110223_a.jpg" width=670 height=476><br>如上图中，我选择的是192.168.0.198这个session标签。点鼠标右键，弹出菜单，选择session option，如下图，设置上传和下载目录<br><img border=0 alt="" src="http://www.cppblog.com/images/cppblog_com/zdhsoft/20110223_b.jpg" width=543 height=502><br>我这里设置的是d:\temp\linux。<br>然后，我们就可以传送文件了。<br>下载文件：进入linux的指目录中，输入命令sz filename,这样就把指定的文件下载到d:\temp\linux中<br>如图所示：<img border=0 alt="" src="http://www.cppblog.com/images/cppblog_com/zdhsoft/20110223_c.jpg" width=670 height=476><br>然后，去你的下载目录d:\temp\linux，就会发现多了一个makefile文件。<br>如果上传文件，同样进入指定目录中，输入命rz，就会有一个选择文件弹出对话框，如下图<img border=0 alt="" src="http://www.cppblog.com/images/cppblog_com/zdhsoft/20110223_d.jpg" width=443 height=400><br>然后，点OK按钮，就可以上传了，结果如下图<br><img border=0 alt="" src="http://www.cppblog.com/images/cppblog_com/zdhsoft/20110223_e.jpg" width=670 height=476><br>OK，剩下的大家就自己发现了，呵呵。</p>
<img src ="http://www.cppblog.com/Jhon/aggbug/140638.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Jhon/" target="_blank">lvweiqiu</a> 2011-02-25 11:52 <a href="http://www.cppblog.com/Jhon/articles/140638.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP中的正则表达式【转】http://peixin229.blog.163.com/blog/static/3591019020099109756390/?fromdm&amp;isFromSearchEngine=yes</title><link>http://www.cppblog.com/Jhon/articles/140615.html</link><dc:creator>lvweiqiu</dc:creator><author>lvweiqiu</author><pubDate>Thu, 24 Feb 2011 14:58:00 GMT</pubDate><guid>http://www.cppblog.com/Jhon/articles/140615.html</guid><wfw:comment>http://www.cppblog.com/Jhon/comments/140615.html</wfw:comment><comments>http://www.cppblog.com/Jhon/articles/140615.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Jhon/comments/commentRss/140615.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Jhon/services/trackbacks/140615.html</trackback:ping><description><![CDATA[<span  style="font-family: Arial, Helvetica, sans-serif; line-height: 28px; font-size: large; ">1 前言&nbsp;<br style="line-height: 28px; ">php被大量的应用于web的后台cgi研发，通常是在用户数据数据之后得出某种结果，但是假如用户输入的数据不正确，就会出现问题，比如说某人的生日是"2月30日"！那应该怎么样来检验暑假是否正确呢？ 在php中加入了正则表达式的支持，让我们能够十分方便的进行数据匹配。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">2 什么是正则表达式：&nbsp;<br style="line-height: 28px; ">简单的说，正则表达式是一种能够用于模式匹配和替换的强大工具。在几乎任何的基于unix/linux系统的软件工具中找到正则表达式的痕迹，例如：perl或php脚本语言。此外，javas<wbr style="line-height: 28px; ">cript这种客户端的脚本语言也提供了对正则表达式的支持，现在正则表达式已成为了一个通用的概念和工具，被各类技术人员所广泛使用。&nbsp;<br style="line-height: 28px; ">在某个linux网站上面有这样的话："假如您问一下linux爱好者最喜欢什么，他可能会回答正则表达式；假如您问他最害怕什么，除了繁琐的安装配置外他肯定会说正则表达式。"&nbsp;<br style="line-height: 28px; ">正如上面说的，正则表达式看起来很复杂，让人害怕，大多数的php初学者都会跳过这里，继续下面的学习，但是php中的正则表达式有着能够利用模式匹配找到符合条件的字符串、判断字符串是否合乎条件或用指定的字符串来替代符合条件的字符串等强大的功能，不学实在太可惜了&#8230;&#8230;&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; "><br style="line-height: 28px; ">3 正则表达式的基本语法：&nbsp;<br style="line-height: 28px; ">一个正则表达式，分为三个部分：分隔符，表达式和修饰符。&nbsp;<br style="line-height: 28px; ">分隔符能够是除了特别字符以外的任何字符（比如"/ !"等等），常用的分隔符是"/"。表达式由一些特别字符（特别字符详见下面）和非特别的字符串组成，比如"[a-z0-9_-]+@[a-z0-9_-.]+"能够匹配一个简单的电子邮件字符串。修饰符是用来开启或关闭某种功能/模式。下面就是个完整的正则表达式的例子：&nbsp;<br style="line-height: 28px; ">/hello.+?hello/is&nbsp;<br style="line-height: 28px; ">上面的正则表达式"/"就是分隔符，两个"/"之间的就是表达式，第二个"/"后面的字符串"is"就是修饰符。&nbsp;<br style="line-height: 28px; ">在表达式中假如含有分隔符，那么就需要使用转义符号"＼"，比如"/hello.+?＼/hello/is"。转义符号除了用于分隔符外还能够执行特别字符，全部由字母构成的特别字符都需要"＼"来转义，比如"＼d"代表全体数字。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; "><br style="line-height: 28px; ">4 正则表达式的特别字符：&nbsp;<br style="line-height: 28px; ">正则表达式中的特别字符分为元字符、定位字符等等。&nbsp;<br style="line-height: 28px; ">元字符是正则表达式中一类有特别意义的字符，用来描述其前导字符（即元字符前面的字符）在被匹配的对象中出现的方式。元字符本身是个个单一的字符，但是不同或相同的元字符组合起来能够构成大的元字符。&nbsp;<br style="line-height: 28px; ">元字符：&nbsp;<br style="line-height: 28px; ">大括号：大括号用来精确指定匹配元字符出现的次数，例如"/pre{1,5}/"表示匹配的对象能够是"pre"、"pree"、"preeeee"这样在"pr"后面出现1个到5个"e"的字符串。或"/pre{,5}/"代表pre出现0此到5次之间。&nbsp;<br style="line-height: 28px; ">加号："+"字符用来匹配元字符前的字符出现一次或多次。例如"/ac+/"表示被匹配的对象能够是"act"、"account"、"acccc"等在"a"后面出现一个或多个"c"的字符串。"+"相当于"{1,}"。&nbsp;<br style="line-height: 28px; ">星号："*"字符用来匹配元字符前的字符出现零次或多次。例如"/ac*/"表示被匹配的对象能够是"app"、"acp"、"accp"等在"a"后面出现零个或多个"c"的字符串。"*"相当于"{0,}"。&nbsp;<br style="line-height: 28px; ">问号："?"字符用来匹配元字符前的字符出现零次或1次。例如"/ac?/"表示匹配的对象能够是"a"、"acp"、"acwp"这样在"a"后面出现零个或1个"c"的字符串。"?"在正则表达式中更有一个很重要的作用，即"贪婪模式"。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">更有两个很重要的特别字符就是"[ ]"。他们能够匹配"[]"之中出现过的字符，比如"/[az]/"能够匹配单个字符"a"或"z"；假如把上面的表达式改成这样"/[a-z]/"，就能够匹配任何单个小写字母，比如"a"、"b"等等。&nbsp;<br style="line-height: 28px; ">假如在"[]"中出现了"^"，代表本表达式不匹配"[]"内出现的字符，比如"/[^a-z]/"不匹配任何小写字母！并且正则表达式给出了几种"[]"的默认值：&nbsp;<br style="line-height: 28px; ">[:alpha:]：匹配任何字母&nbsp;<br style="line-height: 28px; ">[:alnum:]：匹配任何字母和数字&nbsp;<br style="line-height: 28px; ">[:digit:]：匹配任何数字&nbsp;<br style="line-height: 28px; ">[:space:]：匹配空格符&nbsp;<br style="line-height: 28px; ">[:upper:]：匹配任何大写字母&nbsp;<br style="line-height: 28px; ">[:lower:]：匹配任何小写字母&nbsp;<br style="line-height: 28px; ">[:punct:]：匹配任何标点符号&nbsp;<br style="line-height: 28px; ">[:xdigit:]：匹配任何16进制数字&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">另外下面这些特别字符在转义符号"＼"转义后代表的含义如下：&nbsp;<br style="line-height: 28px; ">s：匹配单个的空格符&nbsp;<br style="line-height: 28px; ">s：用于匹配除单个空格符之外的任何字符。&nbsp;<br style="line-height: 28px; ">d：用于匹配从0到9的数字，相当于"/[0-9]/"。&nbsp;<br style="line-height: 28px; ">w：用于匹配字母，数字或下划线字符，相当于"/[a-za-z0-9_]/"。&nbsp;<br style="line-height: 28px; ">w：用于匹配任何和w不匹配的字符，相当于"/[^a-za-z0-9_]/"。&nbsp;<br style="line-height: 28px; ">d：用于匹配任何非10进制的数字字符。&nbsp;<br style="line-height: 28px; ">.：用于匹配除换行符之外的任何字符，假如经过修饰符"s"的修饰，"."能够代表任意字符。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">利用上面的特别字符能够很方便的表达一些比较繁琐的模式匹配。例如"/＼d0000/"利用上面的正则表达式能够匹配万以上，十万一下的整数字符串。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">定位字符：&nbsp;<br style="line-height: 28px; ">定位字符是正则表达式中又一类很重要的字符，他的主要作用是用于对字符在匹配对象中的位置进行描述。&nbsp;<br style="line-height: 28px; ">^：表示匹配的模式出现在匹配对象的开头（和在"[]"里面不同）&nbsp;<br style="line-height: 28px; ">$：表示匹配的模式出现在匹配对象的末尾&nbsp;<br style="line-height: 28px; ">空格：表示匹配的模式出现在开始和结尾的两个边界之一&nbsp;<br style="line-height: 28px; ">"/^he/"：能够匹配以"he"字符开头的字符串，比如hello、height等等；&nbsp;<br style="line-height: 28px; ">"/he$/"：能够匹配以"he"字符结尾的字符串即she等；&nbsp;<br style="line-height: 28px; ">"/ he/"：空格开头，和^的作用相同，匹配以he开头的字符串；&nbsp;<br style="line-height: 28px; ">"/he /"：空格结束，和$的作用相同，匹配以he结尾的字符串；&nbsp;<br style="line-height: 28px; ">"/^he$/"：表示只和字符串"he"匹配。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">括号：&nbsp;<br style="line-height: 28px; ">正则表达式除了能够用户匹配，还能够用括号"()"来记录需要的信息，储存起来，给后面的表达式读取。比如：&nbsp;<br style="line-height: 28px; ">/^([a-za-z0-9_-]+)@([a-za-z0-9_-]+)(.[a-za-z0-9_-])$/&nbsp;<br style="line-height: 28px; ">就是记录邮件地址的用户名，和邮件地址的服务器地址（形式为username@server.com之类的），在后面假如想要读取记录下来的字符串，只是需要用"转义符＋记录的次序"来读取。比如"＼1"就相当于第一个"[a-za-z0-9_-]+"，"＼2"相当于第二个([a-za-z0-9_-]+)，"＼3"就是第三个(.[a-za-z0-9_-])。但是在php中，"＼"是个特别的字符，需要转义，所以""到了php的表达式中就应该写成"＼＼1"。&nbsp;<br style="line-height: 28px; ">其他特别符号：&nbsp;<br style="line-height: 28px; ">"|"：或符号"|"和php里面的或相同，但是是个"|"，而不是php的两个"||"！意思就是能够是某个字符或另一个字符串，比如"/abcd|dcba/"可能匹配"abcd"或"dcba"。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; "><br style="line-height: 28px; ">5 贪婪模式：&nbsp;<br style="line-height: 28px; ">前面在元字符中提到过"?"更有一个重要的作用，即"贪婪模式"，什么是"贪婪模式"呢？&nbsp;<br style="line-height: 28px; ">比如我们要匹配以字母"a"开头字母"b"结尾的字符串，但是需要匹配的字符串在"a"后面含有很多个"b"，比如"a bbbbbbbbbbbbbbbbb"，那正则表达式是会匹配第一个"b"还是最后一个"b"呢？假如您使用了贪婪模式，那么会匹配到最后一个"b"，反之只是匹配到第一个"b"。&nbsp;<br style="line-height: 28px; ">使用贪婪模式的表达式如下：&nbsp;<br style="line-height: 28px; ">/a.+?b/&nbsp;<br style="line-height: 28px; ">/a.+b/u&nbsp;<br style="line-height: 28px; ">不使用贪婪模式的如下：&nbsp;<br style="line-height: 28px; ">/a.+b/&nbsp;<br style="line-height: 28px; ">上面使用了一个修饰符u，详见下面的部分。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; "><br style="line-height: 28px; ">6 修饰符：&nbsp;<br style="line-height: 28px; ">在正则表达式里面的修饰符能够改变正则的很多特性，使得正则表达式更加适合您的需要（注意：修饰符对于大小写是敏感的，这意味着"e"并不等于"e"）。正则表达式里面的修饰符如下：&nbsp;<br style="line-height: 28px; ">i ：假如在修饰符中加上"i"，则正则将会取消大小写敏感性，即"a"和"a" 是相同的。&nbsp;<br style="line-height: 28px; ">m：默认的正则开始"^"和结束"$"只是对于正则字符串假如在修饰符中加上"m"，那么开始和结束将会指字符串的每一行：每一行的开头就是"^"，结尾就是"$"。&nbsp;<br style="line-height: 28px; ">s：假如在修饰符中加入"s"，那么默认的"."代表除了换行符以外的任何字符将会变成任意字符，也就是包括换行符！&nbsp;<br style="line-height: 28px; ">x：假如加上该修饰符，表达式中的空白字符将会被忽略，除非他已被转义。&nbsp;<br style="line-height: 28px; ">e：本修饰符仅仅对于replacement有用，代表在replacement中作为php代码。&nbsp;<br style="line-height: 28px; ">a：假如使用这个修饰符，那么表达式必须是匹配的字符串中的开头部分。比如说"/a/a"匹配"abcd"。&nbsp;<br style="line-height: 28px; ">e：和"m"相反，假如使用这个修饰符，那么"$"将匹配绝对字符串的结尾，而不是换行符前面，默认就打开了这个模式。&nbsp;<br style="line-height: 28px; ">u：和问号的作用差不多，用于配置"贪婪模式"。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; "><br style="line-height: 28px; ">7 pcre相关的正则表达式函数：&nbsp;<br style="line-height: 28px; ">php的perl兼容正则表达式提供的多个函数，分为模式匹配，替换和匹配数目等等：&nbsp;<br style="line-height: 28px; ">1、preg_match ：&nbsp;<br style="line-height: 28px; ">函数格式：int preg_match(string pattern, string subject, array [matches]);&nbsp;<br style="line-height: 28px; ">这个函数会在string中使用pattern表达式来匹配，假如给定了[regs]，就会将string记录到[regs][0]中，[regs][1]代表使用括号"（）"记录下来的第一个字符串，[regs][2]代表记录下来的第二个字符串，以此类推。preg假如在string中找到了匹配的pattern，就会返回"true"，否则返回"false"。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">2、preg_replace ：&nbsp;<br style="line-height: 28px; ">函数格式：mixed preg_replace(mixed pattern, mixed replacement, mixed subject);&nbsp;<br style="line-height: 28px; ">这个函数会使用将string中符合表达式pattern的字符串全部替换为表达式replacement。假如replacement中需要包含pattern的部分字符，则能够使用"()"来记录，在replacement中只是需要用"＼1"来读取。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">3、preg_split ：&nbsp;<br style="line-height: 28px; ">函数格式：array preg_split(string pattern, string subject, int [limit]);&nbsp;<br style="line-height: 28px; ">这个函数和函数split相同，区分仅在和split能够使用简单正则表达式来分割匹配的字符串，而preg_split使用完全的perl兼容正则表达式。第三个参数limit代表允许返回多少个符合条件的值。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">4、preg_grep ：&nbsp;<br style="line-height: 28px; ">函数格式：array preg_grep(string patern , array input);&nbsp;<br style="line-height: 28px; ">这个函数和preg_match功能基本上，但是preg_grep能够将给定的数组input中的任何元素匹配，返回一个新的数组。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">下面举一个例子，比如我们要检查email地址的格式是否正确：&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; "><br style="line-height: 28px; ">function emailisright($email) {&nbsp;<br style="line-height: 28px; ">if (preg_match("^[_＼.0-9a-z-]+@([0-9a-z][0-9a-z-]+＼.)+[a-z]{2,3}$",$email)) {&nbsp;<br style="line-height: 28px; ">return 1;&nbsp;<br style="line-height: 28px; ">}&nbsp;<br style="line-height: 28px; ">return 0;&nbsp;<br style="line-height: 28px; ">}&nbsp;<br style="line-height: 28px; ">if(emailisright(y10k@963.net)) echo 正确<br style="line-height: 28px; ">;&nbsp;<br style="line-height: 28px; ">if(!emailisright(y10k@fffff)) echo 不正确<br style="line-height: 28px; ">;&nbsp;<br style="line-height: 28px; ">?&gt;&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; "><br style="line-height: 28px; ">上面的程式会输出"正确<br style="line-height: 28px; ">不正确"。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">8.php中的perl兼容正则表达式和perl/ereg正则表达式的区分：&nbsp;<br style="line-height: 28px; ">虽然叫做&#8220;perl兼容正则表达式&#8221;，但是和perl的正则表达式相比，php的还是由一些不同，比如修饰符&#8220;g&#8221;在perl里面代表全部匹配，但是在php中没有加入对这个修饰符的支持。&nbsp;<br style="line-height: 28px; ">更有就是和ereg系列函数的区分，ereg也是php中提供的正则表达式函数，但是和preg相比，要弱上很多。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">1、ereg里面是无需也不能使用分隔符和修饰符的，所以ereg的功能比preg要弱上不少。&nbsp;<br style="line-height: 28px; ">2、关于"."：点在正则里面一般是除了换行符以外的全部字符，但是在ereg里面的"."是任意字符，即包括换行符！假如在preg里面希望"."能够包括换行符，能够在修饰符中加上"s"。&nbsp;<br style="line-height: 28px; ">3、ereg默认使用贪婪模式，并且不能修改，这个给很多替换和匹配带来麻烦。&nbsp;<br style="line-height: 28px; ">4、速度：这个或许是很多人关心的问题，会不会preg功能强大是以速度来换取的？不用担心，preg的速度要远远比ereg快，笔者做了一个程式测试：<br style="line-height: 28px; "><br style="line-height: 28px; ">time test:&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">php代码:&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">echo "preg_replace used time:";&nbsp;<br style="line-height: 28px; ">$start = time();&nbsp;<br style="line-height: 28px; ">for($i=1;$i&lt;=100000;$i++) {&nbsp;<br style="line-height: 28px; ">$str = "ssssssssssssssssssssssssssss";&nbsp;<br style="line-height: 28px; ">preg_replace("/s/","",$str);&nbsp;<br style="line-height: 28px; ">}&nbsp;<br style="line-height: 28px; ">$ended = time()-$start;&nbsp;<br style="line-height: 28px; ">echo $ended;&nbsp;<br style="line-height: 28px; ">echo "&nbsp;<br style="line-height: 28px; ">ereg_replace used time:";&nbsp;<br style="line-height: 28px; ">$start = time();&nbsp;<br style="line-height: 28px; ">for($i=1;$i&lt;=100000;$i++) {&nbsp;<br style="line-height: 28px; ">$str = "ssssssssssssssssssssssssssss";&nbsp;<br style="line-height: 28px; ">ereg_replace("s","",$str);&nbsp;<br style="line-height: 28px; ">}&nbsp;<br style="line-height: 28px; ">$ended = time()-$start;&nbsp;<br style="line-height: 28px; ">echo $ended;&nbsp;<br style="line-height: 28px; ">echo "&nbsp;<br style="line-height: 28px; ">str_replace used time:";&nbsp;<br style="line-height: 28px; ">$start = time();&nbsp;<br style="line-height: 28px; ">for($i=1;$i&lt;=100000;$i++) {&nbsp;<br style="line-height: 28px; ">$str = "sssssssssssssssssssssssssssss";&nbsp;<br style="line-height: 28px; ">str_replace("s","",$str);&nbsp;<br style="line-height: 28px; ">}&nbsp;<br style="line-height: 28px; ">$ended = time()-$start;&nbsp;<br style="line-height: 28px; ">echo $ended;&nbsp;<br style="line-height: 28px; ">?&gt;&nbsp;<br style="line-height: 28px; ">结果：&nbsp;<br style="line-height: 28px; ">preg_replace used time:5&nbsp;<br style="line-height: 28px; ">ereg_replace used time:15&nbsp;<br style="line-height: 28px; ">str_replace used time:2&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; ">str_replace因为无需匹配所以速度很快，而preg_replace的速度比ereg_replace要快上不少。&nbsp;<br style="line-height: 28px; "><br style="line-height: 28px; "><br style="line-height: 28px; ">9.关于php3.0对于preg的支持：&nbsp;<br style="line-height: 28px; ">在php 4.0中默认加入了preg支持，但是在3.0中确没有。假如在3.0中希望使用preg函数，必须加载php3_pcre.dll文档，只要在php.ini的extension部分配置加入"extension = php3_pcre.dll"然后从新启动php就能够了！&nbsp;<br style="line-height: 28px; ">其实正则表达式还常用于ubbcode的实现，很多php论坛都使用了这个方法（比如zforum zphp.com或vb vbullent.com），但是具体的代码比较长。</span>
<img src ="http://www.cppblog.com/Jhon/aggbug/140615.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Jhon/" target="_blank">lvweiqiu</a> 2011-02-24 22:58 <a href="http://www.cppblog.com/Jhon/articles/140615.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>