Don't use regular expressions to parse HTML. Use a tool that already knows how to parse HTML. For example, here's how you can get the desired output in XML::XSH2, a wrapper around XML::LibXML:
open :F html file.html ;
echo xsh:join('; ', //ul[@class='test']/li/a) ;