Greetings deprecated,
Well, this isn't the best or most compact regex in the world, but I've tested this, and it appears to work in the trials I've done. Give it a try. Someone with additional regex experience should be able to shorten my match string somewhat, I suspect.
use strict; my $input = "<tr><td><b><a href=i386/zh-xcin-2.3.04.tgz-long.html>zh-x +cin-2.3.04.tgz</a></b></td><td>   <i>chinese input utilit +y for X</i></td><td>[ <a href=ftp://ftp.openbsd.org/pub/OpenBSD/2.8/p +ackages/i386/zh-xcin-2.3.04.tgz>FTP Site 1</a> ]</td><td>[ <a href=ft +p://ftp1.usa.openbsd.org/pub/OpenBSD/2.8/packages/i386/zh-xcin-2.3.04 +.tgz>FTP Site 2</a> ]</td></tr>"; my %data; my @fields = split '<tr><td><b>', $input; shift @fields; foreach my $field (@fields) { ($data{fileurl}, $data{filename}, $data{description}, $data{ftp1}, + $data{ftp2}) = $field =~ m#^<a href=(.*?)>(.*?)</a></b></td><td>   <i>(.*?) +</i></td><td>\[ <a href=(.*?)>.*?</a> ]</td><td>\[ <a href=(.*?)>.*#; print "$2 == $3\n"; }
Yeah, I know. It's a bit clunky. Given additional known constants for your specific situation, you may be able to streamline this a bit better than me. Anyway, good luck!
-Gryphon.
In reply to Re: Regex Exercise
by gryphon
in thread Regex Exercise
by deprecated
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |