in reply to Why doesn't this regex work? (Solved!)

I've looked through it with Regexp::Debugger.

Maybe (probably) I'm misunderstanding the question, but in your sample data, the hundred groups in each line seem to be the same. i.e. $1 + 1 will always not equal $2 in this data, for each line.

I think the second point is about the spaces. When the regex matches, it skips a space, so misses out on matching the next number to the first part of the regex.

For example, this inserts a newline before the 200s start:

#!/usr/bin/perl use strict; use warnings; #use Regexp::Debugger; while( <DATA> ) { s[\s(\d+)\d\d\K\s(?=(\d+)\d\d)]{ $1 + 1 == $2 ? "\n" : ' ' }ge; print; } __DATA__ 105 106 107 108 109 110 211 212 213 1115 1116 1117 1118 1119 1120 1121 1122 1123 12345 12346 12347 12348 12349 12350 12351 12353

But when you change the data to:

105 106 107 108 109 210 211 212 213 1115 1116 1117 1118 1119 1120 1121 1122 1123 12345 12346 12347 12348 12349 12350 12351 12353

the first part of the regex doesn't match the 109, because the match fails on the first space.

Apologies if I'm way off!