in reply to REGEX issue
That is because the "?" in ".*?" makes the ".*" pattern ungreedy
For example, compare:
$str="taaaaaaaa"; $str=~/(ta+)/; print "$1\n"; $str=~/(ta+?)/; print "$1\n";
In your case...
$str =~ m/[^<story>].*<image>(.*)<\/image>.*?[^<\/story>]/s; ## <- w/o the "?" should work
citromatik
UPDATE: I apologize for my answer: although my previous comment is correct and my regexp do the work, the concept of the regexp is totally incorrect. It should be expressed as:
Nevertheless I agree with FunkeyMonk, using XML::Simple would be the best solution.$str=~s/\n//g; $str =~ m%<story>.*</story><image>(.*)</image>%;
|
|---|