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//
//compat-libcap1//
//compat-libstdc++-3//
/Which is almost what you need while the second one is more exact as it
gives you:
/2.23.52.0.1-12//
//1.10-3//
//3.2.3-71//
/And that looks like exactly what you need.
I'm no expert in regex but I like to experiment with it to see if I can
extract some parts from a text / string using it.
Jimmy (bash, perl and python total noob but trying to learn stuff).
On 27.07.2018 15:54, 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 (^[a-zA-Z0-9\-]*)\-\d'
First part of the regular expression is ^[a-zA-Z0-9\-]
which means search for anything that begins with a letter
(lower or upper) or a number up until you reach an
hyphen sign (‘-‘).
but it fails to match
compat-libstdc++-33-3.2.3-71.el7.i686
Please let me know what regex should i use to extract all 3
rpms.
Also let me know if there are web tools to build regex
Good websites for regex tutorials.
Thanks,
--
Asad Hasan
+91 9582111698