http://www.perlmonks.org?node_id=880577

ultranerds has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

Sorry, the subject isn't very descriptive, but wasn't sure how to describe what I'm trying to do =)

I have this string:

my $summary = q~[sommaire Bordeaux à test] [[Hébergement à Bordeaux]] [[Gastronomie à Bordeaux]] [[A voir à Bordeaux]] == a sub header === sub header == foo bar === whatever [[Sorties, vie nocturne à Bordeaux]] [[Suggestions pour Bordeaux]] [/sommaire] ~;


..what I need to do, is has a while () {} which will go through that string, and split it up into the following:

var 1: [[Bordeaux|A propos de Bordeaux]] var 2: [[Gastronomie à Bordeaux]] var 3: [[A voir à Bordeaux]] == a sub header === sub header == foo bar === whatever var 4: [[Sorties, vie nocturne à Bordeaux]] var 5: [[Suggestions pour Bordeaux]]


I've tried quite a few regexes, but I can't seem to get them right (I've just ordered the following book - but that won't arrive for a couple of days, I thought it would be worth my while to read it though, as there is still a ton of stuff I don't know about regexes - should of done this years ago!)

http://www.amazon.co.uk/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124/ref=sr_1_3?s=books&ie=UTF8&qid=1294227606&sr=1-3

TIA!

Andy