我使用的是Ruby1.9.3.我是这个平台的新手.
从文档我刚刚得到了两个anchor是\z和\G.现在我有点玩,\z看它是如何工作的,因为定义(字符串的结束或结束)让我感到困惑,我无法理解它的意思 - 通过End.所以我尝试了下面的小片段.但仍然无法抓住.
码
irb(main):011:0> str = "Hit him on the head me 2\n" + "Hit him on the head wit>
=> "Hit him on the head me 2\nHit him on the head with a 24\n"
irb(main):012:0> str =~ /\d\z/
=> nil
irb(main):013:0> str = "Hit him on the head me 24 2\n" + "Hit him on the head >
=> "Hit …Run Code Online (Sandbox Code Playgroud)