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 | |
by BrowserUk (Patriarch) on Aug 16, 2013 at 09:43 UTC |