in reply to Re^2: grabbing chunks of text
in thread grabbing chunks of text
.* is too permissive. You could use a complicated trick to fix this, but it's easiest to extract the blocks then to filter out the ones you don't want.
If you want to break the blocks at the start of the line, the following will do that for you:@blocks = grep / type =/, /:\w.*?(?=:\w)/sg;
@blocks = grep / type =/, /^[^:]*:\w.*\n(?:[^:]*: .*\n)*/mg;
It also demonstrates how lookahead and the non-greedy modifier can be avoided here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: grabbing chunks of text
by spencerd (Novice) on Mar 10, 2010 at 19:12 UTC | |
by ikegami (Patriarch) on Mar 10, 2010 at 19:32 UTC |