I seek to split text, based on a bunch of keyword in the text, and shove it into a hash. I've been staring at 'Chapter 6: Pattern Matching' in the Perl Cookbook, but I just can't seem to get my mind around it. I'm pretty sure I need to be using the \G anchor, and non-greedy matching, but... I have an array of keywords like
$Keyptr = {PREFACE => 1, ANALYSIS => 1, DEFERRED => 1, 'NAME / NUMBER' => 1, CONCLUSION => 1, EFFECTS => 1, REMARKS => 1}
My input looks like
I want to coerce it into something like@inputs = ("fronttrash PREFACE: mumble ^M ANALYSIS: yada ^M yada CONCLUSION: d +rone drone ^M REMARKS: ixnay", "ANALYSIS: Chuckle REMARKS: Yada2 DEFERRED: blahblah ^M blah ^M NAM +E / NUMBER: John 369")
Is this the thing that can /should be done in a single golfed line? Alternatively, is there a module that I should be looking at?[{PREFACE => "mumble", ANALYSIS => "yada ^M yada", CONCLUSION => "drone drone", REMARKS => "ixnay"}, {ANALYSIS => "Chuckle", REMARKS => "Yada2", "NAME / NUMBER" => "John 369", DEFERRED => "blahblah^M blah"}]
Thanks
Throop
In reply to Regex help - butchering text into paragraphs by throop
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |