perrin has asked for the wisdom of the Perl Monks concerning the following question:
Given data like this:
I want to end up with a hash containing the keys and values implied by this format. This was my first try:<%def .errors> missing_name: You must provide your name. missing_email: You must provide your email address. </%def>
But of course that only gets the first one. Is there a way to get them all without first trimming the text?my %errors = ( $data =~ m|<\%def \.errors>.*?(?:(^\w+):(.*?)$)+.*?</\%def>|sgm );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex parsing brainteaser
by Roy Johnson (Monsignor) on Apr 01, 2008 at 20:35 UTC | |
|
Re: regex parsing brainteaser
by ikegami (Patriarch) on Apr 01, 2008 at 22:32 UTC | |
|
Re: regex parsing brainteaser
by FunkyMonk (Bishop) on Apr 01, 2008 at 22:58 UTC | |
|
Re: regex parsing brainteaser
by poolpi (Hermit) on Apr 02, 2008 at 13:32 UTC |