http://qs1969.pair.com?node_id=439234


in reply to Look behind and global

Hi gingaloon

if you have 12345 then the sequences of two digits are 12 23 34 45...

HTH - Mark

Update: my (guessed) explanation as to why you don't get what you want is that you're not modifying the pattern "in-place", so to speak, so the regexp engine doesn't take account of the changes it makes. This is one use for backreferences (\1 \2 \3)

Update 2: why not just s/(\d\d)/$1\n/g?