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

As your original question seems to have been answered, here, FWIW, is an approach that is neither multi-pass nor dependent on  /e replacement code execution or embedded code blocks as most others seem to be. I was a bit confused by the data output example in the OP, but I have set this up to insert newlines on transitions from one 100s group to the next.

>perl -wMstrict -le "my @lines = ( '105 106 107 108 109 110 111 112 113 220 221 223', '100 101 198 199 200 201 298 299 300 301 398 399 400 401', '1115 1116 1117 1118 1119 1120 1121 1122 1123 1200 1201 1202', '1100 1101 1102 1198 1199 1200 1201 1202 1298 1299 1300 1301', '12345 12346 12347 12348 12349 12450 12451 12453 12466 12467', '12300 12301 12398 12399 12400 12401 12498 12499 12500 12501', ); print qq{'$_'} for @lines; print ''; ;; s{ (\d) \d\d \K [^\n\S]+ (?! \d* \1 \d\d \b) }{\n}xmsg for @lines; print qq{'$_'} for @lines; " '105 106 107 108 109 110 111 112 113 220 221 223' '100 101 198 199 200 201 298 299 300 301 398 399 400 401' '1115 1116 1117 1118 1119 1120 1121 1122 1123 1200 1201 1202' '1100 1101 1102 1198 1199 1200 1201 1202 1298 1299 1300 1301' '12345 12346 12347 12348 12349 12450 12451 12453 12466 12467' '12300 12301 12398 12399 12400 12401 12498 12499 12500 12501' '105 106 107 108 109 110 111 112 113 220 221 223' '100 101 198 199 200 201 298 299 300 301 398 399 400 401' '1115 1116 1117 1118 1119 1120 1121 1122 1123 1200 1201 1202' '1100 1101 1102 1198 1199 1200 1201 1202 1298 1299 1300 1301' '12345 12346 12347 12348 12349 12450 12451 12453 12466 12467' '12300 12301 12398 12399 12400 12401 12498 12499 12500 12501'

Replies are listed 'Best First'.
Re^2: Why doesn't this regex work? (?!bench)
by Anonymous Monk on Aug 16, 2013 at 02:08 UTC

    Nice, doing the least amount of work is the fastest

    5.016003 Rate anoNa anoNb bukA bukB anoM anoNa 461/s -- -59% -90% -90% -94% anoNb 1126/s 144% -- -76% -76% -85% bukA 4662/s 910% 314% -- -0% -40% bukB 4675/s 913% 315% 0% -- -40% anoM 7751/s 1580% 588% 66% 66% --
    FWIW the outputs aren't identical but they're close enough :)

      Even the multi-pass solution I actually used to do the job probably only took 3 or 4 minutes, including the time it took to type the original and then retrieve, edit and re-run each of 5 passes.

      Conversely, I must have spent an hour or two trying to figure out why my first attempt didn't work.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.