闁衡偓閹増顥� (0) +1 閻犙嶆嫹 (0) +1 闂婎亷鎷� (0) +1
闁衡偓閹増顥戦柟瀛樺姇婵拷闁哄被鍎冲﹢鍛村绩閹増顥�>>

正在阅读:关于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      /\*.*?\*/   
察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:
  小结:   ?与/U有类似功能,但同时出现彼此抵消      如下:         2.Assertions   \w+(?=;)      matchesawordfollowedbyasemicolon,butdoesnotinclude   thesemicoloninthematch,and      foo(?!bar)      matchesanyoccurrenceof"foo"thatisnotfollowedby   "bar".Notethattheapparentlysimilarpattern      小结:   (?!)只前向判断匹配,如bar(?!foo),而(?!foo)bar没有意义   (? 察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品
闁归潧顑嗗┃鈧悹浣告健濡拷闁搞儳鍋涢崺灞俱亜閸洖鍔�