Re: regex to get the rpm name version

2018-08-09 Thread Andy Bach
You can put your separators in there as literals to keep them out of captures: $ cat /tmp/ver.pl #!perl while () { if ( /([\w+-]{3,})-([.\d-]+)\./ ) { print "$1 - $2\n"; } print "$_\n"; } __END__ binutils-2.23.52.0.1-12.el7.x86_64 compat-libcap1-1.10-3.el7.x86_64

Re: regex to get the rpm name version

2018-08-09 Thread Home Linux Info
Hello, You can begin with "*[a-zA-Z_+-]{3,}[0-9]*" to get the package name, it needs a little more work for right now it gets the last dash and first digit of package version. Then you can try "*([^a-zA-Z_+-]{3,})(.\d{1,})*". The first regex gives the following result: /binutils-2//

Re: regex to get the rpm name version

2018-07-27 Thread Shlomi Fish
Hi Asad, On Fri, 27 Jul 2018 18:24:39 +0530 Asad wrote: > Hi All , > > I want to get a regex to actually get the rpm name and version for > comparison : > > > binutils-2.23.52.0.1-12.el7.x86_64", > compat-libcap1-1.10-3.el7.x86_64" > compat-libstdc++-33-3.2.3-71.el7.i686 > >

Re: regex to get the rpm name version

2018-07-27 Thread Chas. Owens
But if you have to use a regex, I suggest using the /x modifier to make it easier to read an maintain the regex: #!/usr/bin/perl use strict; use warnings; for my $s (qw/binutils-2.23.52.0.1-12.el7.x86_64 compat-libcap1-1.10-3.el7.x86_64 compat-libstdc++-33-3.2.3-71.el7.i686/) { my ($name,

RE: regex to get the rpm name version

2018-07-27 Thread Duncan Ferguson
I would suggest you change your approach and user the query mode of RPM to get your information instead of build up a regexp: rpm -qa --queryformat "%{NAME}\n" Duncs From: Asad [mailto:asad.hasan2...@gmail.com] Sent: 27 July 2018 13:55 To: beginners@perl.org Subject: regex to get the rpm

Re: regex to get the rpm name version

2018-07-27 Thread Chas. Owens
I don't think a regex is the simplest and most maintainable way to get this information. I think it is probably better to take advantage of the structure of the string to discard and find information: #!/usr/bin/perl use strict; use warnings; for my $s (qw/binutils-2.23.52.0.1-12.el7.x86_64