Date: Thu, 20 Jun 2002 20:48:49 -0400 From: parv <parv@pair.com> To: f-ports <freebsd-ports@freebsd.org> Subject: regex to parse port version/name Message-ID: <20020621004849.GB67220@moo.holy.cow>
next in thread | raw e-mail | index | archive | help
i can't seem to find an e-mail (or the thread) which suggested (discussed) a regex to parse installed port versions/names via google. can anybody provide the pointer to the old thread? here is my (perl) version based on the ports i have installed... m#^(/var/db/pkg/)(.+?)(-(?:no.+?)?(?:\d+[-_.,\w]*|pl.+))$# $1 contains '/var/db/pkg/' $2 port name (w/o version) $3 port version (w/o name) ...this is part of 'listpkg' script to show port name, port name w/ version, & complete /var/db/pkg path ... http://www103.pair.com/parv/comp/unix/bin/listpkg ...besides that shameless plug, how does the regex look? i know at least of one problem if port names happened to be like ghostscript-gnu-nox11-7.05_1 and p5-PlRPC-0.2016. w/ above regex as it is, output would be... ghostscript-gnu ghostscript-gnu-nox11-7.05_1 /var/db/pkg/ghostscript-gnu-nox11-7.05_1 p5 p5-PlRPC-0.2016 /var/db/pkg/p5-PlRPC-0.2016 ...if i allow greedy matching in the 2d capturing regex "(.+)" which makes "(?:no.+?)?" useless ... ghostscript-gnu-nox11 ghostscript-gnu-nox11-7.05_1 /var/db/pkg/ghostscript-gnu-nox11-7.05_1 p5-PlRPC p5-PlRPC-0.2016 /var/db/pkg/p5-PlRPC-0.2016 ...that seems more suitable to me at the expense of longer ghostscript port name. any ideas? - parv -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020621004849.GB67220>