亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3160 | 回復(fù): 3
打印 上一主題 下一主題

ruby 的回溯 正則表達(dá)式 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2012-03-05 20:14 |只看該作者 |倒序?yàn)g覽
ruby 的回溯 正則表達(dá)式





matchesrubyregular expression
Ruby代碼
  1. ^ - Matches beginning of line   
  2. $ - Matches end of line   
  3. \A - Matches beginning of string.   
  4. \Z - Matches end of string. If string ends with a newline, it matches just before newline   
  5. \z - Matches end of string   
  6. \G - Matches point where last match finished   
  7. \b - Matches word boundaries when outside brackets; backspace (0x08) when inside brackets   
  8. \B - Matches non-word boundaries   
  9. (?=pat) - Positive lookahead assertion: ensures that the following characters match pat, but doesn't include those characters in the matched text   
  10. (?!pat) - Negative lookahead assertion: ensures that the following characters do not match pat, but doesn't include those characters in the matched text   
  11. (?<=pat) - Positive lookbehind assertion: ensures that the preceding characters match pat, but doesn't include those characters in the matched text   
  12. (?<!pat) - Negative lookbehind assertion: ensures that the preceding characters do not match pat, but doesn't include those characters in the matched text   
  13. # If a pattern isn't anchored it can begin at any point in the string   
  14.   
  15. /real/.match("surrealist") #=> #<MatchData "real">   
  16. # Anchoring the pattern to the beginning of the string forces the   
  17. # match to start there. 'real' doesn't occur at the beginning of the   
  18. # string, so now the match fails   
  19. /\Areal/.match("surrealist") #=> nil   
  20. # The match below fails because although 'Demand' contains 'and', the   
  21. pattern does not occur at a word boundary.   
  22. /\band/.match("Demand")   
  23. # Whereas in the following example 'and' has been anchored to a   
  24. # non-word boundary so instead of matching the first 'and' it matches   
  25. # from the fourth letter of 'demand' instead   
  26. /\Band.+/.match("Supply and demand curve") #=> #<MatchData "and curve">   
  27. # The pattern below uses positive lookahead and positive lookbehind to   
  28. # match text appearing in <b></b> tags without including the tags in the   
  29. # match   
  30. /(?<=<b>)\w+(?=<\/b>)/.match("Fortune favours the <b>bold</b>")   
  31.     #=> #<MatchData "bold">  


  32. ^ - Matches beginning of line
  33. $ - Matches end of line
  34. \A - Matches beginning of string.
  35. \Z - Matches end of string. If string ends with a newline, it matches just before newline
  36. \z - Matches end of string
  37. \G - Matches point where last match finished
  38. \b - Matches word boundaries when outside brackets; backspace (0x08) when inside brackets
  39. \B - Matches non-word boundaries
  40. (?=pat) - Positive lookahead assertion: ensures that the following characters match pat, but doesn't include those characters in the matched text
  41. (?!pat) - Negative lookahead assertion: ensures that the following characters do not match pat, but doesn't include those characters in the matched text
  42. (?<=pat) - Positive lookbehind assertion: ensures that the preceding characters match pat, but doesn't include those characters in the matched text
  43. (?<!pat) - Negative lookbehind assertion: ensures that the preceding characters do not match pat, but doesn't include those characters in the matched text
  44. # If a pattern isn't anchored it can begin at any point in the string

  45. /real/.match("surrealist") #=> #<MatchData "real">
  46. # Anchoring the pattern to the beginning of the string forces the
  47. # match to start there. 'real' doesn't occur at the beginning of the
  48. # string, so now the match fails
  49. /\Areal/.match("surrealist") #=> nil
  50. # The match below fails because although 'Demand' contains 'and', the
  51. pattern does not occur at a word boundary.
  52. /\band/.match("Demand")
  53. # Whereas in the following example 'and' has been anchored to a
  54. # non-word boundary so instead of matching the first 'and' it matches
  55. # from the fourth letter of 'demand' instead
  56. /\Band.+/.match("Supply and demand curve") #=> #<MatchData "and curve">
  57. # The pattern below uses positive lookahead and positive lookbehind to
  58. # match text appearing in <b></b> tags without including the tags in the
  59. # match
  60. /(?<=<b>)\w+(?=<\/b>)/.match("Fortune favours the <b>bold</b>")
  61.     #=> #<MatchData "bold">
復(fù)制代碼

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2012-03-05 20:43 |只看該作者
謝謝分享

論壇徽章:
3
寅虎
日期:2013-11-27 07:53:29申猴
日期:2014-09-12 09:24:152015年迎新春徽章
日期:2015-03-04 09:48:31
3 [報(bào)告]
發(fā)表于 2012-03-06 09:03 |只看該作者
提示: 作者被禁止或刪除 內(nèi)容自動屏蔽

論壇徽章:
3
寅虎
日期:2013-11-27 07:53:29申猴
日期:2014-09-12 09:24:152015年迎新春徽章
日期:2015-03-04 09:48:31
4 [報(bào)告]
發(fā)表于 2012-03-06 09:15 |只看該作者
提示: 作者被禁止或刪除 內(nèi)容自動屏蔽
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP