On Sun, Jan 28, 2001 at 11:11:02PM +0100, Pixel wrote:
> Prana <[EMAIL PROTECTED]> writes:
>
> > Attached file: drakupdatetxt.tar.bz2
>
> kernel22? The only working solution is something like
> /^(.*)-([^-]+)-([^-]+)\.[^.]+\.rpm$/
>
> aka remove .rpm, remove the arch (must not contain .), remove the release (must
> not contain -), remove the version (must not contain -)
>
>
> I wonder if there is an easy C++ regexp engine that could be used to remove some
> crap like:
>
> colon_location = ftp_site->find(":");
> if (ftp_site->substr(0,colon_location) == *machine)
> // Is it the right update?
> {
> mirrors->push_back(new string( ftp_site->substr(colon_location+1,
>ftp_site->length()) ));
> }
>
> which really is
>
> push @mirrors, $1 if $ftp_site =~ /$machine:(.*)/
>
> (which one is more readable?)
>
One can use regcomp/regexec for this sort of thing. I use it in
MandrakeUpdate and rpmdrake. With a little wrapper (FindMatches), it
is almost as readable as a perl regex-statement ;-)
The code could look like, given that FindMatches() has been translated
to C++:
if (FindMatches(ftp_site, machine+":(.*)", res))
{
mirrors->push_back(res[1]);
}
which pretty much looks like the perl code.
--
[EMAIL PROTECTED]