[#50363] [質問] Ruby socket.send でUDP Packet が出ない? ネットワーク環境によるものか? — <yamataka@...08.itscom.net>

山口と申します。

9 messages 2016/07/27

[ruby-list:50348] Re: usage of `?<='

From: Shugo Maeda <shugo@...>
Date: 2016-07-07 01:33:07 UTC
List: ruby-list #50348
前田です。

2016-07-07 7:18 GMT+09:00 KIRIYAMA Kazuhiko <kiri@kx.openedu.org>:
>> しばらく Ruby を使ってなくて,ちょっと解決できない問題があり
>> ました.肯定的先読み演算子 `?<=' の使い方です.
>
> ↑は「肯定的先読み」→「肯定的後読み」の間違いです.

この場合、必要なのは先読み(?=〜)なんじゃないでしょうか。

a = '@foo
This is 1st foo line 1
This is 1st foo line 2
This is 1st foo line 3
@foo
This is 2nd foo line 1
@foo
This is 3rd foo line 1
This is 3rd foo line 2
'
a.scan(/@foo.*?(?:(?=@foo)|\z)/m) { |s|
  p s
}

In This Thread