Regex lookahead example not as stated in Camel 4th
Bob MacCallum
uncoolbob at gmail.com
Wed Jun 19 15:31:32 BST 2013
I was thinking you'd have to use something like this
perl -wE 'say for "0123456789" =~ /(\d(?=(\d{2})))/g'
0
12
1
23
2
34
3
45
4
56
5
67
6
78
7
89
obviously with some post-processing required.
On Wed, Jun 19, 2013 at 3:28 PM, Bob MacCallum <uncoolbob at gmail.com> wrote:
> so, forgetting the typo for a moment, why doesn't it output
> 012
> 012
> 012
> 012
> ...
> ?
>
> From my reading of the 5.12 perlre docs, there is no mention of moving the
> cursor along by one position after each match.
> Maybe that is a more general thing I wasn't aware of.
>
>
>
>
>
>
> On Wed, Jun 19, 2013 at 3:02 PM, gvim <gvimrc at gmail.com> wrote:
>
>> On 19/06/13 14:52, Abigail wrote:
>>
>>
>>> That's not a lookahead assertion. This is:
>>>
>>> $ perl -wE 'say for "0123456789" =~ /(?=(\d{3}))/g'
>>> 012
>>> 123
>>> 234
>>> 345
>>> 456
>>> 567
>>> 678
>>> 789
>>> $
>>>
>>>
>>>
>> So there's a typo on p.248
>>
>> gvim
>>
>
>
More information about the london.pm
mailing list