Again, I suggest using rpm with --queryformat with something that's not part of the package, like a space or * or something that you could use as your field delimiter. Then the rules for your regular expression make it trivial to get out the bits you want. Like:<div>
<br></div><div>rpm -qa --queryformat '%{name} %{version}-%{release} %{arch}\n'<br><div><br></div><div>-Scott<br><br><div class="gmail_quote">On Sun, Sep 6, 2009 at 10:56 PM, Brian Pitts <span dir="ltr"><<a href="mailto:brian@polibyte.com">brian@polibyte.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 09/06/2009 11:13 AM, Matty wrote:<br>
> Howdy,<br>
><br>
> Does anyone happen to have a sed recipe to split a package name like:<br>
><br>
> yum-metadata-parser-1.1.2-12.fc11.x86_64<br>
><br>
> Into:<br>
><br>
> $1 -> yum-metadata-parser<br>
> $2 -> -1.*<br>
><br>
> I have a working solution in perl and python, but sed is another story.<br>
><br>
<br>
</div>Could you use grep instead of sed? If so, you might be able to reuse<br>
your perl regexp with grep --perl-regexp. Also, here are two simple<br>
egrep expreesions that seem to work.<br>
<br>
$ echo 'yum-metadata-parser-1.1.2-12.fc11.x86_64' | grep -Eo '[-a-z]+[a-z]'<br>
<br>
yum-metadata-parser<br>
fc<br>
<br>
$ echo 'yum-metadata-parser-1.1.2-12.fc11.x86_64' | grep -Eo<br>
'[0-9]+[-.1-9]+fc[0-9]{1,2}.(x86_64|i386)'<br>
<div class="im"><br>
1.1.2-12.fc11.x86_64<br>
<br>
</div>--<br>
All the best,<br>
<font color="#888888">Brian Pitts<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
</div></div></blockquote></div><br></div></div>