正在阅读:关于php正则表达式的两点备注关于php正则表达式的两点备注

2004-02-14 09:33 出处:PConline 作者:seeu1688\CSDN 责任编辑:linjixiong
severaltipsaboutRegularExpressions   1.processfor"greedy"   Bydefault,thequantifiersare"greedy",thatis,they   matchasmuchaspossible(uptothemaximumnumberofper-   mittedtimes),withoutcausingtherestofthepatternto   fail.Theclassicexampleofwherethisgivesproblemsisin   tryingtomatchcommentsinCprograms.Theseappearbetween   thesequences/*and*/andwithinthesequence,individual   *and/charactersmayappear.AnattempttomatchCcom-   mentsbyapplyingthepattern      /\*.*\*/      tothestring      /*firstcommand*/notcomment/*secondcomment*/      fails,becauseitmatchestheentirestringduetothe   greedinessofthe.*item.      However,ifaquantifierisfollowedbyaquestionmark,   thenitceasestobegreedy,andinsteadmatchestheminimum   numberoftimespossible,sothepattern      /\*.*?\*/   
察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:
键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品