in reply to Assigning text sections to scalars
If you insist on using a regex, try: ($title, $author, $abstract) = $article =~ /([^\n]+)(?:\n\n)?/g When I tried your regex, I encountered two cases: 1) with no whitespace after the abstract, in which case I ended up with nothing at all, and 2) with \n\n after the abstract, which left me with the entire block of text in $title; I can't really explain how you could extract only the title but not the others.
By the way, the reason I say to use split in this case is because you don't really care what's in the strings you're extracting -- you only care about what's between them (namely the \n\n), often a strong indication that split is the correct tool to use.
Note that the regex requires a lot more punctuation and is in general harder to comprehend at a glance than the split, but the functionality is essentially the same.
hdp.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Assigning text sections to scalars
by jeroenes (Priest) on Apr 25, 2001 at 13:55 UTC | |
by hdp (Beadle) on Apr 25, 2001 at 18:13 UTC |